Include ID attribute in function.html_select_date.php
[email protected] (Richard Harb)
| Newsgroups | php.smarty.dev |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I added support for inclusion of the ID attribute to
function.html_select_date.php that I believe might make sense to be
included in future releases.
Reason being that I use to add <label> elements for all fields in a
form and the HTML spec requires the <label for="elem"> to be
associated the the ID of a control.
In the version I am submitting the ID will only be included if it is
explicitly requested in the template by providing a value by addding
{html_select_date ... id="string" ...
If the ID should be included by default it can easily be done by
changing the init default from null to a string (copy of $prefix for
example).
While at it I also made the <input ... for the year_as_text xhtml compliant.
(and to follow up on the private email I sent to monte: at first I
also included the addition of access keys to the select elements -
until I reread the specs and realized they are not supposed to be in
there. Duh!)
Richard
CVS diff:
RCS file: /repository/smarty/libs/plugins/function.html_select_date.php,v
retrieving revision 1.28
diff -r1.28 function.html_select_date.php
26a27,28
> * - 1.3.3 added support for id attribute /
> * xhtml compliance on year input field (Richard Harb)
29c31
< * @version 1.3.2
---
> * @version 1.3.3
40c42,43
< $prefix = "Date_";
---
> $prefix = 'Date_';
> $id = null;
84a88
> case 'id':
139c143
<
---
>
185a190,194
> if (null !== $id && null !== $field_array) {
> $month_result .= ' id="' . $field_array . '[' . $id . 'Month]"';
> } elseif (null !== $id) {
> $month_result .= ' id="' . $id . 'Month"';
> }
221a231,235
> if (null !== $id && null !== $field_array) {
> $day_result .= ' id="' . $field_array . '[' . $id . 'Day]"';
> } elseif (null !== $id) {
> $day_result .= ' id="' . $id . 'Day"';
> }
245a260,264
> if (null !== $id && null !== $field_array) {
> $year_id = $field_array . '[' . $id . 'Year]';
> } elseif (null !== $id) {
> $year_id = $id . 'Year';
> }
247a267,269
> if (null !== $id) {
> $year_result .= ' id="' . $year_id . '"';
> }
254c276
< $year_result .= '>';
---
> $year_result .= ' />';