/** * Creates new instance of child form. * * @param int|string $idx * @param \Illuminate\Database\Eloquent\Model|array $model * @return ChildFormType */ private function createChildForm($idx, $model = null) { $name = $this->name . '[' . $idx . ']'; $modelClass = $this->getOption('model'); $form = $modelClass::createForm(null, null, $name, $model); // laravel-from-builder hack to fix error borders on all fields with same name fixFormBuilderForm($form, $this->formHelper->getConfig('defaults.wrapper_error_class')); return new ChildFormType($name, 'form', $this->parent, ['label' => $this->getOption('row_label') . ' #' . (is_string($idx) ? $idx : ++$idx), 'class' => $form]); }
/** * {@inheritDoc} */ protected function createChildren() { $modelClass = $this->getOption('model'); $parentModel = $this->parent->getModel(); $model = !empty($parentModel[$this->name]) ? $parentModel[$this->name] : null; $form = $modelClass::createForm(null, null, $this->name, $model); // laravel-from-builder hack to fix error borders on all fields with the same name fixFormBuilderForm($form, $this->formHelper->getConfig('defaults.wrapper_error_class')); $this->children['form'] = new ChildFormType($this->name, 'form', $this->parent, ['label' => false, 'class' => $form]); }