Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
block_class-3473384
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
block_class-3473384
Commits
ed56365c
Commit
ed56365c
authored
2 years ago
by
renatog
Committed by
renatog
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3273849
by RenatoG: Add the auto-complete on attribute-value field
parent
4fcda2cb
No related branches found
Branches containing commit
Tags
9.4.8
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Service/BlockClassHelperService.php
+11
-0
11 additions, 0 deletions
src/Service/BlockClassHelperService.php
with
11 additions
and
0 deletions
src/Service/BlockClassHelperService.php
+
11
−
0
View file @
ed56365c
...
...
@@ -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'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment