/**
  * @param bool $bindValues should model value be bound to form
  * @return mixed|void
  */
 protected function rebuild($bindValues = false)
 {
     $this->form = $this->getClassFromOptions();
     $this->form->setFormOptions(array('name' => $this->name, 'is_child' => true))->rebuildFields();
     $model = $this->getOption('default_value');
     if ($bindValues && $model) {
         foreach ($this->form->getFields() as $name => $field) {
             $field->setValue($this->getModelValueAttribute($model, $name));
         }
     }
     $this->children = $this->form->getFields();
 }
 /**
  * Prepare options for rendering
  *
  * @param array $options
  * @return array
  */
 protected function prepareOptions(array $options = array())
 {
     $options = $this->formHelper->mergeOptions($this->options, $options);
     if ($this->parent->haveErrorsEnabled()) {
         $this->addErrorClass($options);
     }
     if ($this->getOption('attr.multiple')) {
         $this->name = $this->name . '[]';
     }
     $options['wrapperAttrs'] = $this->formHelper->prepareAttributes($options['wrapper']);
     $options['errorAttrs'] = $this->formHelper->prepareAttributes($options['errors']);
     if ($options['is_child']) {
         $options['labelAttrs'] = $this->formHelper->prepareAttributes($options['label_attr']);
     }
     return $options;
 }
 protected function setupForm(Form $form)
 {
     $form->setFormHelper($this->formHelper)->setFormBuilder($this->formBuilder);
     $form->buildForm();
     return $form;
 }
 function form_rest(Form $form)
 {
     return $form->renderRest(false);
 }