Include ID attribute in function.html_select_date.php

From: Date: Sun, 19 Sep 2004 18:14:10 +0000
Subject: Include ID attribute in function.html_select_date.php
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-2572@lists.php.net to get a copy of this message
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 .= ' />';

« previous php.smarty.dev (#2572) next »