You are here

class FormBuilderPropertyBase in Form Builder 7

Hierarchy

Expanded class hierarchy of FormBuilderPropertyBase

1 string reference to 'FormBuilderPropertyBase'
FormBuilderLoader::loadFormTypeInfo in ./form_builder.classes.inc

File

./form_builder.classes.inc, line 960

View source
class FormBuilderPropertyBase implements FormBuilderPropertyInterface {
  protected $property;
  protected $params;
  protected $formTypeName;

  /**
   * {@inheritdoc}
   */
  public function __construct($property, $params, $form_type_name) {
    $this->property = $property;
    $this->params = $params;
    $this->formTypeName = $form_type_name;
  }

  /**
   * {@inheritdoc}
   */
  public function form(&$form_state, $element) {
    $e = $element
      ->render();
    if (isset($this->params['form']) && function_exists($this->params['form'])) {
      $function = $this->params['form'];
      $p = $this->property;

      // Set a default value on the property to avoid notices.
      $e['#' . $p] = isset($e['#' . $p]) ? $e['#' . $p] : NULL;
      return $function($form_state, $this->formTypeName, $e, $p);
    }
    return array();
  }

  /**
   * {@inheritdoc}
   */
  public function submit($form, &$form_state) {
    if (isset($this->params['submit'])) {
      foreach ($this->params['submit'] as $function) {
        if (function_exists($function)) {
          $function($form, $form_state);
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormBuilderPropertyBase::$formTypeName protected property
FormBuilderPropertyBase::$params protected property
FormBuilderPropertyBase::$property protected property
FormBuilderPropertyBase::form public function Generate form-API elements for editing this property. Overrides FormBuilderPropertyInterface::form 1
FormBuilderPropertyBase::submit public function Submit handler for the editing form(). Overrides FormBuilderPropertyInterface::submit 1
FormBuilderPropertyBase::__construct public function Construct a new instance of this property class. Overrides FormBuilderPropertyInterface::__construct 1