Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
3c46cb94
Commit
3c46cb94
authored
Jul 19, 2014
by
pupi1985
Committed by
Scott
Oct 28, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a way to match selected options by key instead of only values in comboboxes
parent
c93c7997
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
qa-theme-base.php
qa-include/qa-theme-base.php
+21
-3
No files found.
qa-include/qa-theme-base.php
View file @
3c46cb94
...
...
@@ -1231,11 +1231,29 @@
}
public
function
form_select
(
$field
,
$style
)
/**
* Parameters received:
* * tags: Optional. Tags or attributes added after the "<select" html tag
* * options: Required. A key-value array containing all the options in the select. This parameter can be an empty array
* which would result in an empty HTML select
* * value: Optional. The selected value from the 'options' parameter
* * match_by: Optional. Possible values are 'key' or 'value'. Defaults to 'value'. Determines if the value set in the 'value'
* parameter is compared to the key or to the value from the 'options' parameter. This parameter has no effect if the 'value'
* parameter is not set
*/
{
$this
->
output
(
'<select '
.@
$field
[
'tags'
]
.
' class="qa-form-'
.
$style
.
'-select">'
);
$this
->
output
(
'<select '
.
(
isset
(
$field
[
'tags'
])
?
$field
[
'tags'
]
:
''
)
.
' class="qa-form-'
.
$style
.
'-select">'
);
// Only match by key if it is explicitly specified. Otherwise, for backwards compatibility, match by value
$matchbykey
=
isset
(
$field
[
'match_by'
])
&&
$field
[
'match_by'
]
===
'key'
;
foreach
(
$field
[
'options'
]
as
$tag
=>
$value
)
$this
->
output
(
'<option value="'
.
$tag
.
'"'
.
((
$value
==
@
$field
[
'value'
])
?
' selected'
:
''
)
.
'>'
.
$value
.
'</option>'
);
foreach
(
$field
[
'options'
]
as
$key
=>
$value
)
{
$selected
=
isset
(
$field
[
'value'
])
&&
(
(
$matchbykey
&&
$key
===
$field
[
'value'
])
||
(
!
$matchbykey
&&
$value
===
$field
[
'value'
])
);
$this
->
output
(
'<option value="'
.
$key
.
'"'
.
(
$selected
?
' selected'
:
''
)
.
'>'
.
$value
.
'</option>'
);
}
$this
->
output
(
'</select>'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment