HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Date format problem: year isn't displayed if first
csakip
New
Hi,
I tried to add a date input to the form with the order: year, month, day - national standard. The year doesn't get displayed. If the year is second or third then it displays fine.
No year:echo $Sender->Form->Date('date', array('Fields' => array('year','month','day')));
Ok:echo $Sender->Form->Date('date', array('Fields' => array('month','year','day')));
-1
Comments
@csakip
I think you may need to set in locale.php or definitions.php whichever you are using. try modifying Date.DefaultFormat to see if you get the results you want.
e.g.
$Definition['Date.DefaultFormat']=''%Y %e %B';
the code - for Date in class.format.php
http://www.php.net/manual/en/function.date.php
or make your own routine if that doesn't work.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Thanks, but it's not about the displaying date as text but the date inputs on forms. (btw: nice work on the enhanced members list )
Thx. if you don't get help from anyone else and you want to post the whole routine code that I could actually run and experiment with - I would be glad to give it a try.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
That's all the code. Just try to add anywhere where you have a Form object:
$Sender->Form->Date('date', array('Fields' => array('year','month','day')));
Only the month and day dropdowns will be displayed.
You are absolutely correct - it won't work - I think there is a bug in the code for
/library/core/form.php
notice the concatenation is missing in the first switch statement so the loop will always drop the previous results. I haven't confirmed if it saves correctly but it does display the option boxes correctly.
can you confirm please?
if you need a year range option also - this works.
$this->Form->Date($mydate, array('yearrange'=>'1999-2004','Fields' => array('year','month','day')));
without the change the sort works properly with out year (so we know the sorting ability was intended).
echo $this->Form->Date($mydate, array('Fields' => array('day','month')));
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@Todd does this look like a bug and will the "change above" cause other problems.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
same issue in vanilla 2.1 on line 715
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
For visuals before adding the period before the equal sign in
/library/core/form.php line 707
before
$Return = $this->DropDown($FieldName . '_Month', $Months, $Attributes);
results in image1 - if I use this form statement in a plugin
echo $this->Form->Date('date', array('Fields' => array('year','month','day')));
notice it drops the year
after correcting library/core/form.php line 707
changing = to .= for concatenation. results in image2
$Return .= $this->DropDown($FieldName . '_Month', $Months, $Attributes);
same echo statement
echo $this->Form->Date('date', array('Fields' => array('year','month','day')));
also modified line 698 to initialize $Return to "" .
$Fields = ArrayValueI('fields', $Attributes, array('month', 'day', 'year'));
// added this statement
$Return = "";
click on the images to see full display.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I must have some dyslexia. I've checked that part of the code for half an hour and didn't see the missing dot.
Cheers, thank you.
looking forward to your plugins. You have some great ideas.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I'll fix that bug in Gdn_Form.
Yes Boy its all good! www.google.com
http://www.facebook.com