1 | <?php |
||
6 | class ConsoleForm extends Form |
||
|
|||
7 | { |
||
8 | /** |
||
9 | * @var ContentController |
||
10 | */ |
||
11 | protected $controller; |
||
12 | |||
13 | /** |
||
14 | * @param Controller $controller |
||
15 | * @param string $name |
||
16 | */ |
||
17 | public function __construct(Controller $controller, $name) |
||
18 | { |
||
19 | $this->controller = $controller; |
||
20 | |||
21 | $fields = $this->getCustomFields(); |
||
22 | $actions = $this->getCustomActions(); |
||
23 | $validator = $this->getCustomValidator($fields); |
||
24 | |||
25 | parent::__construct($controller, $name, $fields, $actions, $validator); |
||
26 | |||
27 | $this->setFormAction('/console/'.$name); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param array $data |
||
32 | * @param ConsoleForm $form |
||
33 | * @param SS_HTTPRequest $request |
||
34 | */ |
||
35 | public function submitForm($data, ConsoleForm $form, SS_HTTPRequest $request) |
||
41 | |||
42 | /** |
||
43 | * @return FieldList |
||
44 | */ |
||
45 | public function getCustomFields() |
||
53 | |||
54 | /** |
||
55 | * @return FieldList |
||
56 | */ |
||
57 | public function getCustomActions() |
||
65 | |||
66 | public function getCustomValidator(FieldList $fields) |
||
74 | |||
75 | /** |
||
76 | * Add required stars to field labels. |
||
77 | * |
||
78 | * @param array $required |
||
79 | * @param FieldList $fields |
||
80 | */ |
||
81 | protected function setRequiredFieldsLabels($required, FieldList $fields) |
||
82 | { |
||
83 | foreach ((array) $required as $req) { |
||
84 | $field = $fields->dataFieldByName($req); |
||
85 | if ($field && $title = trim($field->Title())) { |
||
86 | $this->setCustomValidationMessage($field, $title); |
||
87 | $field->setTitle($title.' *'); |
||
88 | } |
||
89 | } |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Add is $Field is required message. |
||
94 | * |
||
95 | * @param FormField $field |
||
96 | * @param $title |
||
97 | */ |
||
98 | protected function setCustomValidationMessage(FormField $field, $title) |
||
105 | } |
||
106 |
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.