Skip to content
Snippets Groups Projects
Commit ed56365c authored by renatog's avatar renatog Committed by renatog
Browse files

Issue #3273849 by RenatoG: Add the auto-complete on attribute-value field

parent 4fcda2cb
No related branches found
Tags 9.4.8
No related merge requests found
......@@ -648,6 +648,7 @@ class BlockClassHelperService {
$maxlength_multiple_attributes = $config->get('maxlength_attributes');
}
// Add the attribute key item.
$form['multiple_attributes']['third_party_settings']['block_class']['attribute_' . $index]['attribute_key_' . $index] = [
'#type' => 'textfield',
'#title' => $this->t('Attribute Key'),
......@@ -661,6 +662,7 @@ class BlockClassHelperService {
$form['multiple_attributes']['third_party_settings']['block_class']['attribute_' . $index]['attribute_key_' . $index]['#autocomplete_route_name'] = 'block_class.autocomplete_attributes';
}
// Add the attribute value item.
$form['multiple_attributes']['third_party_settings']['block_class']['attribute_' . $index]['attribute_value_' . $index] = [
'#type' => 'textfield',
'#title' => $this->t('Attribute Value'),
......@@ -669,8 +671,15 @@ class BlockClassHelperService {
'#maxlength' => $maxlength_multiple_attributes,
];
// Enable the auto-complete only is selected in the settings page.
if (!empty($config->get('enable_auto_complete'))) {
$form['multiple_attributes']['third_party_settings']['block_class']['attribute_' . $index]['attribute_value_' . $index]['#autocomplete_route_name'] = 'block_class.autocomplete_attribute_values';
}
$form['multiple_attributes']['third_party_settings']['block_class']['attribute_' . $index]['#attributes']['class'][] = 'multiple-textfield-attribute';
// Show this attribute only if it's the first one of if already exists
// a value. (Editing the block).
if ($index == 0 || (!empty($attribute_key) && !empty($attribute_value))) {
$form['multiple_attributes']['third_party_settings']['block_class']['attribute_' . $index]['#attributes']['class'][] = 'displayed-attribute-field';
}
......@@ -679,6 +688,7 @@ class BlockClassHelperService {
}
}
// Add the button to add another attribute item.
$form['multiple_attributes']['add_another_attribute'] = [
'#type' => 'button',
'#value' => 'Add another attribute',
......@@ -686,6 +696,7 @@ class BlockClassHelperService {
$form['multiple_attributes']['add_another_attribute']['#attributes']['class'][] = 'block-class-add-another-attribute';
// Add the button to remove an attribute item.
$form['multiple_attributes']['remove_attribute'] = [
'#type' => 'button',
'#value' => 'Remove attribute',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment