You are here

protected static function WebformElementStates::buildOperations in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Element/WebformElementStates.php \Drupal\webform\Element\WebformElementStates::buildOperations()

Build a state's operations.

Parameters

string $table_id: The option element's table id.

int $row_index: The option's row index.

array $ajax_settings: An array containing Ajax callback settings.

Return value

array A render array containing state operations.

2 calls to WebformElementStates::buildOperations()
WebformElementStates::buildConditionRow in src/Element/WebformElementStates.php
Build condition row.
WebformElementStates::buildStateRow in src/Element/WebformElementStates.php
Build state row.

File

src/Element/WebformElementStates.php, line 541

Class

WebformElementStates
Provides a webform element to edit an element's #states.

Namespace

Drupal\webform\Element

Code

protected static function buildOperations($table_id, $row_index, array $ajax_settings) {
  $operations = [
    '#wrapper_attributes' => [
      'class' => [
        'webform-states-table--operations',
      ],
    ],
  ];
  $operations['add'] = [
    '#type' => 'image_button',
    '#title' => t('Add'),
    '#src' => drupal_get_path('module', 'webform') . '/images/icons/plus.svg',
    '#limit_validation_errors' => [],
    '#submit' => [
      [
        get_called_class(),
        'addConditionSubmit',
      ],
    ],
    '#ajax' => $ajax_settings,
    '#row_index' => $row_index,
    '#name' => $table_id . '_add_' . $row_index,
  ];
  $operations['remove'] = [
    '#type' => 'image_button',
    '#title' => t('Remove'),
    '#src' => drupal_get_path('module', 'webform') . '/images/icons/minus.svg',
    '#limit_validation_errors' => [],
    '#submit' => [
      [
        get_called_class(),
        'removeRowSubmit',
      ],
    ],
    '#ajax' => $ajax_settings,
    '#row_index' => $row_index,
    '#name' => $table_id . '_remove_' . $row_index,
  ];
  return $operations;
}