1 | <?php |
||
10 | class EditableTextField extends EditableFormField { |
||
|
|||
11 | |||
12 | private static $singular_name = 'Text Field'; |
||
13 | |||
14 | private static $plural_name = 'Text Fields'; |
||
15 | |||
16 | private static $db = array( |
||
17 | 'MinLength' => 'Int', |
||
18 | 'MaxLength' => 'Int', |
||
19 | 'Rows' => 'Int(1)', |
||
20 | 'Placeholder' => 'Varchar(255)' |
||
21 | ); |
||
22 | |||
23 | private static $defaults = array( |
||
24 | 'Rows' => 1 |
||
25 | ); |
||
26 | |||
27 | public function getCMSFields() { |
||
28 | $this->beforeUpdateCMSFields(function($fields) { |
||
29 | $fields->addFieldToTab( |
||
30 | 'Root.Main', |
||
31 | NumericField::create( |
||
32 | 'Rows', |
||
33 | _t('EditableTextField.NUMBERROWS', 'Number of rows') |
||
34 | )->setDescription(_t( |
||
35 | 'EditableTextField.NUMBERROWS_DESCRIPTION', |
||
36 | 'Fields with more than one row will be generated as a textarea' |
||
37 | )) |
||
38 | ); |
||
39 | |||
40 | $fields->addFieldToTab( |
||
41 | 'Root.Main', |
||
42 | TextField::create( |
||
43 | 'Placeholder', |
||
44 | _t('EditableTextField.PLACEHOLDER', 'Placeholder') |
||
45 | ) |
||
46 | ); |
||
47 | }); |
||
48 | |||
49 | return parent::getCMSFields(); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @return FieldList |
||
54 | */ |
||
55 | public function getFieldValidationOptions() { |
||
71 | |||
72 | /** |
||
73 | * @return TextareaField|TextField |
||
74 | */ |
||
75 | public function getFormField() { |
||
91 | |||
92 | /** |
||
93 | * Updates a formfield with the additional metadata specified by this field |
||
94 | * |
||
95 | * @param FormField $field |
||
96 | */ |
||
97 | protected function updateFormField($field) { |
||
115 | } |
||
116 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.