You are here

public function Explode::buildConfigurationForm in Tamper 8

Form constructor.

Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.

Parameters

array $form: An associative array containing the initial structure of the plugin form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Return value

array The form structure.

Overrides TamperBase::buildConfigurationForm

File

src/Plugin/Tamper/Explode.php, line 38

Class

Explode
Plugin implementation of the explode plugin.

Namespace

Drupal\tamper\Plugin\Tamper

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form[self::SETTING_SEPARATOR] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('String separator'),
    '#default_value' => $this
      ->getSetting(self::SETTING_SEPARATOR),
    '#description' => $this
      ->t('This will break up sequenced data into an
      array. For example, "a, b, c" would get broken up into the array(\'a\',
      \'b\', \'c\'). A space can be represented by %s, tabs by %t, and newlines
      by %n.'),
  ];
  $form[self::SETTING_LIMIT] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Limit'),
    '#default_value' => $this
      ->getSetting(self::SETTING_LIMIT),
    '#description' => $this
      ->t('If limit is set and positive, the returned
        items will contain a maximum of limit with the last item containing the
        rest of string. If limit is negative, all components except the last
        -limit are returned. If the limit parameter is zero, then this is
        treated as 1. If limit is not set, then there will be no limit on the
        number of items returned.'),
  ];
  return $form;
}