Hi, I brought this up before on the old Semantic Forms list [1]. At the time I thought it was a viable solution to put my own custom made buttons into the forms where I need them, and I used the HTMLets extension for that.
The problem with this solution is, that it's quite unmaintainable. I have to specify the ID numbers of the HTML input elements, and as soon as I change the form, those change, and have to be adjusted in the files that get included via the HTMLets extension. So I thought it would be much better to have that functionality directly in Semantic Forms (where the ID numbers are known). Today I got around adding this to Semantic Forms, the patch against a recent SVN checkout is attached. It adds a button titled "Today" and a button titled "Yesterday" next to each date input. In our SMW/SF application it is desirable to have this for all date input fields, but I guess in others, where the dates are historical ones, or otherwise never "today" or "yesterday", they would be useless. So this should probably be configurable, or maybe there should be two new input types, 'date_buttons' and 'datetime_buttons', or something like that. Or is this feature so useless to anyone else, that it should not be included in Semantic Forms? Yaron, what do you think? Patrick. [1]: http://groups.google.com/group/semantic-forms/msg/eda41d40bda28d26? -- Key ID: 0x86E346D4 http://patrick-nagel.net/key.asc Fingerprint: 7745 E1BE FA8B FBAD 76AB 2BFC C981 E686 86E3 46D4
Index: includes/SF_FormInputs.inc =================================================================== --- includes/SF_FormInputs.inc (revision 53634) +++ includes/SF_FormInputs.inc (working copy) @@ -479,6 +479,24 @@ $text .= SFFormInputs::monthDropdownHTML($month, $input_name, $is_disabled); } $text .= ' <input tabindex="' . $sfgTabIndex . '" id="' . $input_id . '_year" name="' . $input_name . '[year]" type="text" value="' . $year . '" size="4" ' . $disabled_text . '/>' . "\n"; + + // Button to conveniently input current date + $sfgTabIndex++; + $text .= ' <input type="button" id="' . $input_id . '_todaybutton" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[todaybutton]" value="Today" '; + $text .= 'onClick="mydate=new Date(); myday=mydate.getDate(); document.createbox.' . $input_id . '_day.value=myday; '; + $text .= ' mymonth=new String(\'0\' + parseInt(mydate.getMonth()+1)).slice(-2); document.createbox.' . $input_id . '_month.value=mymonth; '; + $text .= ' document.createbox.' . $input_id . '_year.value=mydate.getFullYear();"'; + $text .= " $disabled_text/> " . "\n"; + + // Button to conveniently input yesterday's date + $sfgTabIndex++; + $text .= ' <input type="button" id="' . $input_id . '_yesterdaybutton" tabindex="' . $sfgTabIndex . '" name="' . $input_name . '[yesterdaybutton]" value="Yesterday" '; + $text .= 'onClick="mydate=new Date(); mydate.setDate(mydate.getDate()-1); '; + $text .= ' myday=mydate.getDate(); document.createbox.' . $input_id . '_day.value=myday; '; + $text .= ' mymonth=new String(\'0\' + parseInt(mydate.getMonth()+1)).slice(-2); document.createbox.' . $input_id . '_month.value=mymonth; '; + $text .= ' document.createbox.' . $input_id . '_year.value=mydate.getFullYear();"'; + $text .= " $disabled_text/> " . "\n"; + $text .= " <span id=\"$info_id\" class=\"errorMessage\"></span>"; return array($text, null); }
------------------------------------------------------------------------------
_______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel