You are here

public function FlexiformElementFlexiform::form in Flexiform 7

Overrides FlexiformElement::form().

Overrides FlexiformElement::form

File

includes/element/flexiform.element.inc, line 66
Contains FlexiformElementFlexiform class.

Class

FlexiformElementFlexiform
Class to embed one flexiform inside another.

Code

public function form($form, &$form_state, $entity) {
  $form = parent::form($form, $form_state, $entity);
  $sub_form = array(
    '#parents' => $form['#parents'] + array(
      $this->element_namespace,
    ),
  );
  $builder = $this
    ->getFlexiform()
    ->getBuilder($entity);
  $form[$this->element_namespace]['#flexiform_builder'] = $builder;
  $form[$this->element_namespace]['#flexiform_element'] = $this;
  $form[$this->element_namespace]['#flexiform'] = $this
    ->getFlexiform();
  $form[$this->element_namespace]['#type'] = 'fieldset';
  $form[$this->element_namespace]['#title'] = $this
    ->label();
  $form[$this->element_namespace] += $builder
    ->form($sub_form, $form_state, $entity);
  return $form;
}