Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
7b87ff1a
Commit
7b87ff1a
authored
Jan 19, 2006
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#45365
by chx: critical bugfix: Fix and simplify selection options.
parent
f828c0ad
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/form.inc
+16
-15
16 additions, 15 deletions
includes/form.inc
with
16 additions
and
15 deletions
includes/form.inc
+
16
−
15
View file @
7b87ff1a
...
...
@@ -469,35 +469,36 @@ function form_options_flatten($array, $reset = TRUE) {
function
theme_select
(
$element
)
{
$select
=
''
;
$size
=
$element
[
'#size'
]
?
' size="'
.
$element
[
'#size'
]
.
'"'
:
''
;
return
theme
(
'form_element'
,
$element
[
'#title'
],
'<select name="'
.
$element
[
'#name'
]
.
''
.
(
$element
[
'#multiple'
]
?
'[]'
:
''
)
.
'"'
.
(
$element
[
'#multiple'
]
?
' multiple="multiple" '
:
''
)
.
drupal_attributes
(
$element
[
'#attributes'
])
.
' id="'
.
$element
[
'#id'
]
.
'" '
.
$size
.
'>'
.
form_select_options
(
$element
)
.
'</select>'
,
$element
[
'#description'
],
$element
[
'#id'
],
$element
[
'#required'
],
form_get_error
(
$element
));
}
function
form_select_options
(
$element
,
$choices
=
NULL
)
{
if
(
!
isset
(
$choices
))
{
$choices
=
$element
[
'#options'
];
}
// array_key_exists() accomodates the rare event where $element['#value'] is NULL.
// isset() fails in this situation.
$value_valid
=
isset
(
$element
[
'#value'
])
||
array_key_exists
(
'#value'
,
$element
);
$value_is_array
=
is_array
(
$element
[
'#value'
]);
foreach
(
$element
[
'#options'
]
as
$key
=>
$choice
)
{
$options
=
''
;
foreach
(
$choices
as
$key
=>
$choice
)
{
if
(
is_array
(
$choice
))
{
$select
.
=
'<optgroup label="'
.
$key
.
'">'
;
foreach
(
$choice
as
$key
=>
$choice
)
{
if
(
$value_valid
&&
(
$element
[
'#value'
]
==
$key
||
(
$value_is_array
&&
isset
(
$element
[
'#value'
][
$key
]))))
{
$selected
=
' selected="selected"'
;
}
else
{
$selected
=
''
;
}
$select
.
=
'<option value="'
.
$key
.
'"'
.
$selected
.
'>'
.
check_plain
(
$choice
)
.
'</option>'
;
}
$select
.
=
'</optgroup>'
;
$options
.
=
'<optgroup label="'
.
$key
.
'">'
;
$options
.
=
form_select_options
(
$element
,
$choice
);
$options
.
=
'</optgroup>'
;
}
else
{
if
(
$value_valid
&&
(
$element
[
'#value'
]
==
$key
||
(
$value_is_array
&&
isset
(
$element
[
'#value'
][
$key
]))))
{
$key
=
(
string
)
$key
;
if
(
$value_valid
&&
(
$element
[
'#value'
]
==
$key
||
(
$value_is_array
&&
in_array
(
$key
,
$element
[
'#value'
]))))
{
$selected
=
' selected="selected"'
;
}
else
{
$selected
=
''
;
}
$
select
.
=
'<option value="'
.
$key
.
'"'
.
$selected
.
'>'
.
check_plain
(
$choice
)
.
'</option>'
;
$
options
.
=
'<option value="'
.
$key
.
'"'
.
$selected
.
'>'
.
check_plain
(
$choice
)
.
'</option>'
;
}
}
return
theme
(
'form_element'
,
$element
[
'#title'
],
'<select name="'
.
$element
[
'#name'
]
.
''
.
(
$element
[
'#multiple'
]
?
'[]'
:
''
)
.
'"'
.
(
$element
[
'#multiple'
]
?
' multiple="multiple" '
:
''
)
.
drupal_attributes
(
$element
[
'#attributes'
])
.
' id="'
.
$element
[
'#id'
]
.
'" '
.
$size
.
'>'
.
$select
.
'</select>'
,
$element
[
'#description'
],
$element
[
'#id'
],
$element
[
'#required'
],
form_get_error
(
$element
))
;
return
$options
;
}
/**
...
...
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