У меня есть дополнительное поле Data
, добавленное к отношению многие ко многим, и я понятия не имею, как его редактировать.
Функция
private static $belongs_many_many = [
'Model' => Model::class
];
Модель
private static $many_many = [
'Features' => Feature::class,
];
private static $many_many_extraFields = [
'Features' => [
'SortOrder' => 'Int',
'Data' => 'Varchar'
]
];
-- / --
$features = Feature::get();
$searchFeaturesButton = new GridFieldAddExistingSearchButton();
$searchFeaturesButton->setSearchList($features);
$featureConfig = GridFieldConfig_RelationEditor::create();
$featureConfig->removeComponentsByType([GridFieldAddExistingAutocompleter::class, GridFieldEditButton::class, GridFieldAddNewButton::class]);
$featureConfig->addComponent(new GridFieldOrderableRows());
$featureConfig->addComponent($searchFeaturesButton);
$featureGrid = GridField::create('Features', 'Features', $this->Features(), $featureConfig);
$field->addFieldToTab('Root.Main', $featureGrid);
-- / --
Как просмотреть Data
как столбец в моем GridField и сделать его редактируемым?
Сортировка работает нормально, так как она управляетсяGridfieldOrderableRows()