Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
viewsreference_filter
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
viewsreference_filter
Commits
c1b9a6dc
Commit
c1b9a6dc
authored
3 months ago
by
Rodolfo Candido
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3201294
by azinck, 3li, Dega: Taxonomy autocomplete shows "Array" after settings are saved
parent
8f78b895
No related branches found
Branches containing commit
Tags
1.0.0-alpha17
Tags containing commit
1 merge request
!9
Resolve #3201294 "Taxonomy autocomplete shows"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/ViewsReferenceSetting/ViewsReferenceExposedFilters.php
+39
-35
39 additions, 35 deletions
...in/ViewsReferenceSetting/ViewsReferenceExposedFilters.php
with
39 additions
and
35 deletions
src/Plugin/ViewsReferenceSetting/ViewsReferenceExposedFilters.php
+
39
−
35
View file @
c1b9a6dc
...
...
@@ -64,9 +64,8 @@ class ViewsReferenceExposedFilters extends PluginBase implements ViewsReferenceS
* {@inheritdoc}
*/
public
function
alterFormField
(
&
$form_field
)
{
$view
=
$this
->
viewsUtility
->
loadView
(
$this
->
configuration
[
'view_name'
],
$this
->
configuration
[
'display_id'
]);
$view
=
$this
->
viewsUtility
->
loadView
(
$this
->
configuration
[
'view_name'
],
$this
->
configuration
[
'display_id'
]);
if
(
!
$view
)
{
$form_field
=
[];
return
;
...
...
@@ -87,40 +86,45 @@ class ViewsReferenceExposedFilters extends PluginBase implements ViewsReferenceS
// values as exposed input.
$view
->
setExposedInput
(
$current_values
);
$form_state
=
(
new
FormState
())
->
setStorage
([
'view'
=>
$view
,
'display'
=>
$view
->
display_handler
->
display
,
]);
// Let form plugins know this is for exposed widgets.
// @see ViewExposedForm::buildForm()
$form_state
->
set
(
'exposed'
,
TRUE
);
// Go through each handler and let it generate its exposed widget.
// @see ViewExposedForm::buildForm()
foreach
(
$view
->
display_handler
->
handlers
as
$type
=>
$value
)
{
/** @var \Drupal\views\Plugin\views\HandlerBase $handler */
foreach
(
$view
->
$type
as
$handler
)
{
if
(
$handler
->
canExpose
()
&&
$handler
->
isExposed
())
{
$handler
->
buildExposedForm
(
$form_field
,
$form_state
);
if
(
$info
=
$handler
->
exposedInfo
())
{
if
(
isset
(
$form_field
[
$info
[
'value'
]]))
{
// Method buildExposedForm() gets rid of element titles, unless
// type is 'checkbox'. So restore it if missing.
if
(
empty
(
$form_field
[
$info
[
'value'
]][
'#title'
]))
{
$form_field
[
$info
[
'value'
]][
'#title'
]
=
$this
->
t
(
'@label'
,
[
'@label'
=>
$info
[
'label'
]]);
}
if
(
empty
(
$form_field
[
$info
[
'value'
]][
'#description'
])
&&
!
empty
(
$info
[
'description'
]))
{
$form_field
[
$info
[
'value'
]][
'#description'
]
=
$info
[
'description'
];
}
// If we are using the exposed form, render it.
// So we can get the form elements to display.
if
(
$view
->
display_handler
->
usesExposed
())
{
/** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form */
$exposed_form
=
$view
->
display_handler
->
getPlugin
(
'exposed_form'
);
$rendered_form
=
$exposed_form
->
renderExposedForm
();
foreach
([
'#info'
,
'#theme'
]
as
$el
)
{
$form_field
[
$el
]
=
$rendered_form
[
$el
];
}
// Manually set default values, until we don't handle these
// properly from form_state.
// @todo use (Sub)FormState to handle default_value.
if
(
isset
(
$current_values
[
$info
[
'value'
]]))
{
$form_field
[
$info
[
'value'
]][
'#default_value'
]
=
$current_values
[
$info
[
'value'
]];
// Go through each handler and let it generate its exposed widget.
// @see ViewExposedForm::buildForm()
foreach
(
$view
->
display_handler
->
handlers
as
$type
=>
$value
)
{
/** @var \Drupal\views\Plugin\views\HandlerBase $handler */
foreach
(
$view
->
$type
as
$handler
)
{
if
(
$handler
->
canExpose
()
&&
$handler
->
isExposed
())
{
if
(
$info
=
$handler
->
exposedInfo
())
{
if
(
isset
(
$rendered_form
[
$info
[
'value'
]]))
{
$form_field
[
$info
[
'value'
]]
=
$rendered_form
[
$info
[
'value'
]];
// Unset attributes that are not relevant for this context and
// to ensure that submitted values are appropriately mapped
// deep into the form_state tree structure.
foreach
([
'#tree'
,
'#parents'
,
'#array_parents'
,
'#name'
,
'#processed'
,
]
as
$el
)
{
unset
(
$form_field
[
$info
[
'value'
]][
$el
]);
}
// The handling of default values for exposed filters seems to
// be really odd. Default values are mapped directly into #value
// by the views handlers. This prevents us from properly handling
// new user-submitted values.
$form_field
[
$info
[
'value'
]][
'#default_value'
]
=
$form_field
[
$info
[
'value'
]][
'#value'
];
unset
(
$form_field
[
$info
[
'value'
]][
'#value'
]);
}
}
}
...
...
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