/** * Return a GridField configured for editing attached MediaModels. If the master record is in the database * then also add GridFieldOrderableRows (otherwise complaint re UnsavedRelationList not being a DataList happens). * * @param string|null $relationshipName * @param string|null $configClassName name of grid field configuration class otherwise one is manufactured * @return \GridField */ protected function gridField($relationshipName = null, $configClassName = null) { $relationshipName = $relationshipName ?: static::RelationshipName; $config = $this->gridFieldConfig($relationshipName, $configClassName); /** @var GridField $gridField */ $gridField = \GridField::create($relationshipName, $relationshipName, $this->owner->{$relationshipName}(), $config); return $gridField; }
/** * Adds many_many relationships based off relationship_name and related_class_name, and many_many_extraFields such as 'Sort'. * * @param null $class * @param null $extension * @return array */ public function extraStatics($class = null, $extension = null) { $extra = []; if (static::sortable()) { $extra = ['many_many_extraFields' => [static::relationship_name() => [static::SortFieldName => 'Int']]]; } return array_merge_recursive(parent::extraStatics($class, $extension), $extra, ['many_many' => [static::relationship_name() => static::related_class_name()]]); }
public function extraStatics($class = null, $extension = null) { return array_merge_recursive(parent::extraStatics($class, $extension) ?: [], ['has_many' => [static::RelationshipName => static::RelatedClassName]]); }