public function open(ModelForm $form, $attributes = []) { if ($this->containers) { throw new \RuntimeException('Prior call to close() is required'); } if (is_string($attributes)) { $attributes = $this->parseAttributes($attributes); } foreach ($attributes as $attribute => $value) { $form->setAttribute($attribute, $value); } $this->containers[] = $form; return '<form' . $this->implodeAttributes($form->getAttributes()) . ">\n"; }
public function setUp() { $addressFieldSet = new FieldSet('address'); $address = $addressFieldSet->setEntity('Address'); $addressFieldSet->add((new Element\Text('street'))->setLabel('Street')->setAttribute('placeholder', 'Enter street')->setFilters('required|trim')); $addressFieldSet->add((new Element\Text('city'))->setLabel('City')->setAttribute('placeholder', 'Enter city')->setFilters('required|trim')); $userFieldSet = new FieldSet('user'); $user = $userFieldSet->setEntity('User'); $user->setAddress($address); $userFieldSet->add((new Element\Text('firstName'))->setLabel('First name')->setAttribute('placeholder', 'Enter first name')->setFilters('required|trim')); $userFieldSet->add((new Element\Text('lastName'))->setLabel('Last name')->setAttribute('placeholder', 'Enter last name')->setFilters('required|trim')); $userFieldSet->add($addressFieldSet); $form = new Form(); $form->add($userFieldSet); $this->form = $form; }