mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-24 09:42:43 +01:00
Recognize Field
instances in Fields::__construct()
and handle them properly
This commit is contained in:
parent
25f79bfa58
commit
efae07d411
@ -15,8 +15,15 @@ class Fields extends AssociativeCollection
|
|||||||
public function __construct(array $fields)
|
public function __construct(array $fields)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
foreach ($fields as $name => $data) {
|
foreach ($fields as $key => $value) {
|
||||||
$this->items[$name] = new Field($name, $data);
|
if ($value instanceof Field) {
|
||||||
|
if (is_int($key)) {
|
||||||
|
$key = $value->name();
|
||||||
|
}
|
||||||
|
$this->items[$key] = $value;
|
||||||
|
} else {
|
||||||
|
$this->items[$key] = new Field($key, $value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user