ProductAttributeType::getCMSFields PHP Method

getCMSFields() public method

public getCMSFields ( )
    public function getCMSFields()
    {
        $fields = FieldList::create(TextField::create("Name", _t('ProductAttributeType.db_Name', 'Name')), TextField::create("Label", _t('ProductAttributeType.db_Label', 'Label')));
        if ($this->isInDB()) {
            $fields->push(GridField::create("Values", _t('ProductAttributeType.has_many_Values', "Values"), $this->Values(), GridFieldConfig_RecordEditor::create()));
        } else {
            $fields->push(LiteralField::create("Values", '<p class="message warning">' . _t('ProductAttributeType.SaveFirstInfo', 'Save first, then you can add values.') . '</p>'));
        }
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }

Usage Example

 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $values = $fields->fieldByname("Values");
     if ($values instanceof GridField) {
         $values->setModelClass("ColoredProductAttributeValue");
     }
     return $fields;
 }