Results 1 to 5 of 5

Thread: Form date field not stored fully [solved with own mod]

  1. #1
    User
    Join Date
    01-22-10.
    Location
    Trowbridge, UK
    Posts
    61

    Default 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

  2. #2
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default 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.

  3. #3
    User
    Join Date
    01-22-10.
    Location
    Trowbridge, UK
    Posts
    61

    Default 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

    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!

  4. #4
    User
    Join Date
    01-22-10.
    Location
    Trowbridge, UK
    Posts
    61

    Default 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
    // Fields
    foreach ($arrSubmitted as $k=>$v)
    {
    if ($k != 'cc' && $k != 'id')
    {
    $arrSet[$k] = $v;
    }
    }
    I changed it to
    // 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

  5. #5
    New user
    Join Date
    08-28-09.
    Posts
    19

    Default 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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •