Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
radix-3257146
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
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
radix-3257146
Commits
c65b73dd
Commit
c65b73dd
authored
8 years ago
by
shadcn
Browse files
Options
Downloads
Patches
Plain Diff
Fix template for checkboxes and radios
parent
3fe8ad5a
No related branches found
Branches containing commit
Tags
8.x-2.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/form.inc
+11
-0
11 additions, 0 deletions
includes/form.inc
templates/form/form-element-label.html.twig
+36
-0
36 additions, 0 deletions
templates/form/form-element-label.html.twig
with
47 additions
and
0 deletions
includes/form.inc
+
11
−
0
View file @
c65b73dd
...
...
@@ -25,3 +25,14 @@ function radix_preprocess_input(&$variables) {
// Add the element type to the theme.
$variables
[
'type'
]
=
$element
[
'#type'
];
}
/**
* Implements template_preprocess_form_element().
*/
function
radix_preprocess_form_element
(
&
$variables
)
{
// Render the form element inside the label for checkbox and radio.
if
(
in_array
(
$variables
[
'element'
][
'#type'
],
[
'checkbox'
,
'radio'
]))
{
$variables
[
'label'
][
'#children'
]
=
$variables
[
'children'
];
unset
(
$variables
[
'children'
]);
}
}
This diff is collapsed.
Click to expand it.
templates/form/form-element-label.html.twig
0 → 100644
+
36
−
0
View file @
c65b73dd
{#
/**
* @file
* Default theme implementation for a form element label.
*
* Available variables:
* - element: an input element.
* - title: The label's text.
* - title_display: Elements title_display setting.
* - description: element description.
* - required: An indicator for whether the associated form element is required.
* - attributes: A list of HTML attributes for the label.
*
* @see template_preprocess_form_element_label()
*
* @ingroup templates
*/
#}
{%
-
set
classes
=
[
title_display
==
'after'
?
'option'
,
title_display
==
'invisible'
?
'visually-hidden'
,
required
?
'js-form-required'
,
required
?
'form-required'
,
]
-
%}
{%
-
if
title
is
not
empty
or
required
-
%}
<label
{{
attributes.addClass
(
classes
)
}}
>
{{
element
}}
{{
title
}}
{%
-
if
description
-
%}
<p
class=
"help-block"
>
{{
description
}}
</p>
{%
-
endif
-
%}
</label>
{%
-
if
required
and
title_display
==
'before'
-
%}
<span
class=
"form-required"
>
*
</span>
{%
-
endif
-
%}
{%
-
endif
-
%}
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