/** * @param mixed $val * * @return ChildFormType */ protected function setValue($val) { parent::setValue($val); $this->createChildren(); return $this; }
/** * Set up a single child element for a collection * * @param FormField $field * @param $name * @param null $value * @return FormField */ protected function setupChild(FormField $field, $name, $value = null) { $newFieldName = $field->getName() . $name; $firstFieldOptions = $this->formHelper->mergeOptions($this->getOption('options'), ['attr' => ['id' => $newFieldName]]); $field->setName($newFieldName); $field->setOptions($firstFieldOptions); if ($value && !$field instanceof ChildFormType) { $value = $this->getModelValueAttribute($value, $this->getOption('property')); } $field->setValue($value); return $field; }