Form date field not stored fully [solved with own mod]
using catalog & catalog ext I've defined a date_seen field as format date
[attachment=2:3s56vmu7]table date field.jpg[/attachment:3s56vmu7]
then using the form generator defined a Date Seen input field
[attachment=1:3s56vmu7]form date field.jpg[/attachment:3s56vmu7]
Note only Text format option is available
I now input the data
[attachment=0:3s56vmu7]form date entry.jpg[/attachment:3s56vmu7]
the date is correctly checked for format, so I know the form knows it's a date field
but in the database it gets stored as just 2010 (i.e. year only)
(sorry can seem to attach any more images)
and that is what is displayed in the Catalog Detail page
Re: Form date field not stored fully
This is because its not wise to use the FORM generator to enter data into the Catalog... We've built the Alpha version to do just that...
The form posts the date as you enter it to the database, which of course is not in tstamp format. In the catalog edit module (part of the alpha 2), we take the date text, convert it back to tstamp and then store it into the DB.
Re: Form date field not stored fully
Thanks thyon
Looks like waiting for the new version is going to be the best option and as I'm still in development mode it might be worth trying alpha 2, especially as you say in
Quote:
Originally Posted by http://www.typolight-community.org/viewtopic.php?f=27&t=1054&p=4047&hilit=catalog+alp a%E2%80%A6#p4128
this post
that
Quote:
actually catalog 2 is pretty much a stable alpha2 version, and best thing is that your modules and data remain intact in the upgrade.
But I will back up first!
Re: Form date field not stored fully
Quote:
Originally Posted by thyon
The form posts the date as you enter it to the database, which of course is not in tstamp format. In the catalog edit module (part of the alpha 2), we take the date text, convert it back to tstamp and then store it into the DB.
OK. My first mod!
In the Form.php module at line 388 the code is
Quote:
// Fields
foreach ($arrSubmitted as $k=>$v)
{
if ($k != 'cc' && $k != 'id')
{
$arrSet[$k] = $v;
}
}
I changed it to
Quote:
// Fields
foreach ($arrSubmitted as $k=>$v)
{
if ($k != 'cc' && $k != 'id')
{
// Mod by AEC
if ($k == 'date_seen') // my form date field
{
$arrSet[$k] = strtotime($v);
}
else {
$arrSet[$k] = $v;
}
// End of Mod by AEC
}
}
Keeps me going until Catalog 2
Re: Form date field not stored fully [solved with own mod]
Thank you, Alan. 2 years after you, I am looking for a solution to a similar problem, and will make use of your modification.
Bart.