You are here

public function Property::form in Form Builder 7.2

Same name in this branch
  1. 7.2 examples/src/Property.php \Drupal\form_builder_examples\Property::form()
  2. 7.2 modules/webform/src/Property.php \Drupal\form_builder_webform\Property::form()

Generate form-API elements for editing this property.

Parameters

array $form_state: Form API form_state of the field configure form.

\Drupal\form_builder\ElementInterface $element: The currently stored element. Use this to get the "current" values.

Return value

array Form-API array that will be merged into the field configure form.

File

examples/src/Property.php, line 27

Class

Property
Form builder property for the example form type.

Namespace

Drupal\form_builder_examples

Code

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();
}