| 1 | <?php |
||
| 21 | class GroupField extends Field |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * A list of class properties to be added to attributes. |
||
| 25 | * |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | protected $injectedProperties = []; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * The field's default element. |
||
| 32 | * |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | protected $element = 'div'; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * List of managed fields. |
||
| 39 | * |
||
| 40 | * @var array |
||
| 41 | */ |
||
| 42 | protected $fields = []; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Set managed fields. |
||
| 46 | * |
||
| 47 | * @param array $fields |
||
| 48 | * |
||
| 49 | * @return $this |
||
| 50 | */ |
||
| 51 | 8 | public function fields(array $fields) |
|
| 52 | { |
||
| 53 | array_walk($fields, function (&$field, $name) { |
||
| 54 | 8 | $field = \Form::element($this->name . '[' . $name . ']', $field); |
|
|
1 ignored issue
–
show
|
|||
| 55 | 8 | $field->setAttribute('id', $this->name . '-' . $name); |
|
| 56 | 8 | }); |
|
| 57 | 8 | $this->fields = $fields; |
|
| 58 | |||
| 59 | 8 | return $this; |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Render the field. |
||
| 64 | * |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | 8 | public function render() |
|
| 68 | { |
||
| 69 | 8 | $this->addClass('group-fields'); |
|
| 70 | 8 | $this->setId(); |
|
| 71 | 8 | $this->removeAttribute('value'); |
|
| 72 | |||
| 73 | 8 | return $this->open() . $this->getContent() . $this->close(); |
|
| 74 | 8 | } |
|
| 75 | |||
| 76 | /** |
||
| 77 | * Render the field content. Rendering the managed fields. |
||
| 78 | * |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | 8 | public function getContent() |
|
| 82 | { |
||
| 83 | 8 | $output = ''; |
|
| 84 | 8 | foreach ($this->fields as $field) { |
|
| 85 | 8 | $output .= $field->__toString(); |
|
| 86 | 8 | } |
|
| 87 | |||
| 88 | 8 | return $output; |
|
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Returns values stored in managed fields. |
||
| 93 | * |
||
| 94 | * @return array |
||
| 95 | */ |
||
| 96 | public function getValue() |
||
| 97 | { |
||
| 98 | if (!is_array($this->fields)) { |
||
| 99 | return []; |
||
|
1 ignored issue
–
show
|
|||
| 100 | } |
||
| 101 | |||
| 102 | return array_map(function (Field $field) { |
||
|
1 ignored issue
–
show
|
|||
| 103 | return $field->getValue(); |
||
| 104 | }, $this->fields); |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Set the matching ID on a field if possible |
||
| 109 | * Override to prefix the id with group-. |
||
| 110 | * |
||
| 111 | * @param string $name |
||
| 112 | * |
||
| 113 | * @return string |
||
| 114 | */ |
||
| 115 | 8 | protected function getUniqueId($name) |
|
| 119 | } |
||
| 120 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.