protected static function YamlFormElementStates::buildConditionRow in YAML Form 8
Build condition row.
Parameters
array $element: The form element.
array $condition: The condition.
string $table_id: The element's table id.
int $row_index: The row index.
array $ajax_settings: An array containing AJAX callback settings.
Return value
array A render array containing a condition table row.
1 call to YamlFormElementStates::buildConditionRow()
- YamlFormElementStates::processYamlFormStates in src/
Element/ YamlFormElementStates.php - Expand an email confirm field into two HTML5 email elements.
File
- src/
Element/ YamlFormElementStates.php, line 263
Class
- YamlFormElementStates
- Provides a form element to edit an element's #states.
Namespace
Drupal\yamlform\ElementCode
protected static function buildConditionRow(array $element, array $condition, $table_id, $row_index, array $ajax_settings) {
$condition += [
'selector' => '',
'trigger' => '',
'value' => '',
];
$element_name = $element['#name'];
$trigger_selector = ":input[name=\"{$element_name}[states][{$row_index}][trigger]\"]";
$row = [
'#attributes' => [
'class' => [
'yamlform-states-table--condition',
],
],
];
$row['state'] = [];
$row['selector'] = [
'#type' => 'yamlform_select_other',
'#options' => $element['#selector_options'],
'#default_value' => $condition['selector'],
'#empty_option' => '',
'#empty_value' => '',
'#attributes' => [
'class' => [
'js-yamlform-select2',
'yamlform-select2',
],
],
];
$row['trigger'] = [
'#type' => 'select',
'#options' => $element['#trigger_options'],
'#default_value' => $condition['trigger'],
'#empty_option' => '',
'#empty_value' => '',
'#attributes' => [
'class' => [
'js-yamlform-select2',
'yamlform-select2',
],
],
];
$row['value'] = [
'#type' => 'textfield',
'#title' => t('Value'),
'#title_display' => 'invisible',
'#size' => 25,
'#default_value' => $condition['value'],
'#states' => [
'visible' => [
$trigger_selector => [
'value' => 'value',
],
],
],
];
$row['operations'] = self::buildOperations($table_id, $row_index, $ajax_settings);
return $row;
}