1
|
|
|
<?php namespace StudioBonito\SilverStripe\Inuit\Forms; |
2
|
|
|
|
3
|
|
|
use FieldList; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* A base form class that transforms all fields to use inuit style extensions. |
7
|
|
|
* |
8
|
|
|
* @author Tom Densham <[email protected]> |
9
|
|
|
* @copyright Studio Bonito Ltd. |
10
|
|
|
*/ |
11
|
|
|
class InuitForm extends \Form |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Set the forms template. |
15
|
|
|
* |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected $template = 'InuitForm'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Transform all the {@link \FormField} objects in |
22
|
|
|
* the {@link \FieldList} to use inuit form templates. |
23
|
|
|
* |
24
|
|
|
* @param \FieldList $fields |
25
|
|
|
*/ |
26
|
|
|
public static function perform_inuit_fieldlist_transformation(FieldList $fields) |
27
|
|
|
{ |
28
|
|
|
$fields->performInuitTransformation(); |
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Transform all the {@link \FormField} objects in |
33
|
|
|
* the {@link \Form} field and action {@link \FieldList} |
34
|
|
|
* objects to use inuit form templates. |
35
|
|
|
*/ |
36
|
|
|
public function performInuitTransformation() |
37
|
|
|
{ |
38
|
|
|
$this->performInuitFieldListTransformation($this->Fields()); |
|
|
|
|
39
|
|
|
$this->performInuitFieldListTransformation($this->Actions()); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Transform all the {@link \FormField} objects in |
44
|
|
|
* the {@link \FieldList} to use inuit form templates. |
45
|
|
|
* |
46
|
|
|
* @param \FieldList $fields |
47
|
|
|
* |
48
|
|
|
* @return $this |
49
|
|
|
*/ |
50
|
|
|
protected function performInuitFieldListTransformation(FieldList $fields) |
51
|
|
|
{ |
52
|
|
|
self::perform_inuit_fieldlist_transformation($fields); |
53
|
|
|
|
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Apply the transformation before rendering the form HTML output. |
59
|
|
|
* |
60
|
|
|
* @return mixed |
61
|
|
|
*/ |
62
|
|
|
public function forTemplate() |
63
|
|
|
{ |
64
|
|
|
$this->performInuitTransformation(); |
65
|
|
|
|
66
|
|
|
return parent::forTemplate(); |
67
|
|
|
} |
68
|
|
|
} |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.