You are here

class FormBuilderWebformProperty in Form Builder 7

Hierarchy

Expanded class hierarchy of FormBuilderWebformProperty

1 string reference to 'FormBuilderWebformProperty'
form_builder_webform_form_builder_form_types in modules/webform/form_builder_webform.module
Implements hook_form_builder_form_types().

File

modules/webform/form_builder_webform.classes.inc, line 203

View source
class FormBuilderWebformProperty extends FormBuilderPropertyBase {
  protected $storageParents;

  /**
   * {@inheritdoc}
   */
  public function __construct($property, $params, $form_type_name) {
    $params += array(
      'storage_parents' => array(
        $property,
      ),
    );
    parent::__construct($property, $params, $form_type_name);
    $this->storageParents = $params['storage_parents'];
  }

  /**
   * {@inheritdoc}
   */
  public function setValue(&$component, $value) {
    drupal_array_set_nested_value($component, $this->storageParents, $value);
  }

  /**
   * {@inheritdoc}
   */
  public function form(&$form_state, $element) {

    // We use the rendered element here to re-use the form-API functions.
    $e = $element
      ->render();
    $e += array(
      "#{$this->property}" => $this
        ->getValue($e['#webform_component']),
    );

    // Set weight to just anything. Element positions aren't configured in
    // this way in form_builder.
    $e['#webform_component']['weight'] = 0;
    if (isset($this->params['form']) && function_exists($this->params['form'])) {
      $function = $this->params['form'];
      return $function($form_state, $this->formTypeName, $e, $this->property);
    }
    return array();
  }

  /**
   * Read the value from a component array.
   */
  public function getValue($component) {
    return drupal_array_get_nested_value($component, $this->storageParents);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormBuilderPropertyBase::$formTypeName protected property
FormBuilderPropertyBase::$params protected property
FormBuilderPropertyBase::$property protected property
FormBuilderPropertyBase::submit public function Submit handler for the editing form(). Overrides FormBuilderPropertyInterface::submit 1
FormBuilderWebformProperty::$storageParents protected property
FormBuilderWebformProperty::form public function Generate form-API elements for editing this property. Overrides FormBuilderPropertyBase::form
FormBuilderWebformProperty::getValue public function Read the value from a component array.
FormBuilderWebformProperty::setValue public function 2
FormBuilderWebformProperty::__construct public function Construct a new instance of this property class. Overrides FormBuilderPropertyBase::__construct