You are here

public function SubmitButtonLabel::configurationForm in Flexiform 8

The configuration form.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

array The form with any additions.

Overrides ConfigurableFormEnhancerInterface::configurationForm

File

src/Plugin/FormEnhancer/SubmitButtonLabel.php, line 33

Class

SubmitButtonLabel
FormEnhancer for altering the labels of submit buttons.

Namespace

Drupal\flexiform\Plugin\FormEnhancer

Code

public function configurationForm(array $form, FormStateInterface $form_state) {
  foreach ($this
    ->locateSubmitButtons() as $path => $label) {
    $original_path = $path;
    $path = str_replace('][', '::', $path);
    $form['label'][$path] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('@label Button Text', [
        '@label' => $label,
      ]),
      '#description' => 'Array Parents: ' . $original_path,
      '#default_value' => !empty($this->configuration[$path]) ? $this->configuration[$path] : '',
    ];
  }
  return $form;
}