는 :
http://doc.silverstripe.org/framework/en/tutorials/5-dataobject-relationship-management
나는 관계에 대한 속성을 기록하고 싶습니다 . 그래서 예를 들어 "active"- 프로젝트의 멘토를위한 예/아니오 필드. 그러나 멘토는 자신이 관련된 여러 프로젝트에 대해 다른 가치를 가질 수 있습니다.
Silverstripe에 내장 된 도구로이를 수행하는 가장 좋은 방법은 무엇입니까?
업데이트 아래의 답변은 IRC &의 도움을 받았습니다. ive는 조금 더 가깝게되었고, 비트는 작동하지 않았습니다. 필자는 이것을 찾았습니다 : https://github.com/chillu/silverstripe-framework/blob/c8136f5d4c8a37a4da274cd1c93907c0a2af86a7/docs/en/reference/grid-field.md 매우 관련있는 것 같습니다.
그래서 DebatePages에는 각 토론에서 다르게 투표 할 수있는 많은 패널 토론자가 있습니다.
DebatePage.php
private static $many_many = array(
'Panelists' => 'Panelist',
'RelationTags' => 'Tag'
);
public static $many_many_extraFields = array(
'Panelists' => array('Motion' => 'Boolean')
);
public function getCMSFields() {
.....
if($this->ID) {
$panelistFields = singleton('Panelist')->getCMSFields();
$panelistFields->addFieldToTab(
'Root.Main',
// Please follow the "ManyMany[<extradata-name>]" convention
new TextField('ManyMany[Motion]', 'Agree with Motion')
);
$config = GridFieldConfig_RelationEditor::create();
$config->getComponentByType('GridFieldDetailForm')->setFields($panelistFields);
$gridField = new GridField('Panelists', 'Panelists', $this->Panelists(), $config);
$fields->findOrMakeTab('Root.Panelists')->replaceField('Panelist', $gridField);
}
}
확인 감사합니다. 나는 3.0에 있지만 어쩌면 이것이 너무 유효 할 것 같습니다. 이것에 대한 문서가 전혀 없습니까? 꽤 잘 작동하지 않습니다 – Will
$ config var - 그게 뭐죠? 그 원인은 "부재 개체 getComponentByType()에 대한 호출"오류 – Will
GridField를 통해 ManyMany 필드를 편집하는 것은 SS 3.1 베타 1에서 도입되었으므로 3.0에서 사용하면 사용할 수 없습니다. 커밋을보고 3.0 (https://github.com/silverstripe/silverstripe-framework/commit/c8136f5d4c8a37a4da274cd1c93907c0a2af86a)으로 포팅하거나 3.1로 업그레이드하면 좋은 생각 일 수 있습니다. '$ config' var는 GridField를 생성하는 부분입니다. 이전에는 모든 부분이 없었기 때문에 매우 간단한 코드 조각이었습니다. 위의 대답을 GridField의 전체 코드로 편집하고에 대한 링크를 추가했습니다. 의사.덕분에 – colymba