Years in Widget:type Date
10 posts
• Page 1 of 1
This is one of those simple things that I have been planning to deal with for a while but haven't got around to it. You need to make a modification to Dataface_QuickForm.php to make this work:
In the method _buildWidget(), there is a switch clause where it goes: switch ( $widget['type'] ){ ... case 'htmlarea': ... case 'calendar:'... ... } You need to add a special case for date as follows: case 'date': $el =& $form->addElement('date', $field['name'], $widget['label'], $widget); break; Now you can specify options for the date widget in the fields.ini file as follows: [mydate] widget:type=date widget:language=en ; specify the language format of the date widget:format='dMY' ; Specify the date format widget:minYear=1956 ; The minimum year to select widget:maxYear=2000 ; The maximum year to select I have added this modification to my local dev copy so it will be part of the next minor release. Best regards Steve
Hi Steve
I have used the date formatting command above and it comes up fine when editing, but in list and view mode the date is displayed in YYYY-MM-DD format. Is there a way to make it more user friendly e.g DD-mmm-YY (2-Dec-06) or something similar? Many thanks Neil
Yes.. You can override the display for any field in the delegate class using methods of the form:
%fieldname%__display(&$record) e.g.:
This would format the startdate field like 'February 25, 2006'. Hope this helps.. -Steve
This should work. I tested it before posting it. Can you double check your code. (e.g. make sure there are two underscores, etc...).
This strategy will work for any field regardless of type. -Steve
Things that it could possibly be (checklist):
1. Name of ItemDate field is case sensitive. 2. The ItemDate field is actually in a different table than the delegate class for which the ItemDate__display() method is defined. 3. ... can't think of anything else right now ... Let me know if it is either of those. -Steve
10 posts
• Page 1 of 1
Who is onlineUsers browsing this forum: No registered users and 23 guests |