ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Split entry_date into multiple fields

November 13, 2010 3:06pm

Subscribe [4]
  • #1 / Nov 13, 2010 3:06pm

    BrandonDurham

    74 posts

    I have a custom SAEF setup using SafeCracker. This form allows users to post events and set the entry_date, which I’m equating to the Start Date of an event. I currently have the entry_date set up in my form as a jQuery datepicker but the client would prefer the date be separated out into four select menus: month/day/year/time. A usability nightmare, sure, but they’re insisting.

    Is this possible? If so, how?

    [Mod Edit: Moved to the CodeShare Corner forum]

  • #2 / Feb 23, 2011 9:18pm

    aircrash

    293 posts

    Did you ever figure this out? I’m in basically the same situation right now.

  • #3 / Feb 24, 2011 3:17am

    Mark Bowen

    12637 posts

    I’ve never used the jQuery datepicker but I’m sure there must be one that allows for different configurations of it so that you could have four different types in each of the fields for whatever they’re choosing?

    I really would love to know why they’re insisting they have it in that way though? Sometimes clients insist something and a lot of the time it’s because they think it would be easier or nicer looking or something like that. Once you explain to them other ways they start to come around.

    I really can’t think of any reason for doing it that way so I’d love to know why they said they want it that way?

    Best wishes,

    Mark

  • #4 / Feb 24, 2011 9:15am

    the3mus1can

    426 posts

    You could create the three selects used for the date selection and then just write some js that would aggregates all three values on select change and pass that into a hidden field for the entry_date.

  • #5 / Feb 24, 2011 9:48am

    Mark Bowen

    12637 posts

    You could create the three selects used for the date selection and then just write some js that would aggregates all three values on select change and pass that into a hidden field for the entry_date.

    That also would work if you know for a fact that javascript won’t be an issue and also you need the date stored as literal figures however if you are going to want to do anything meaningful in the future with the date then it would really need to be stored as a Unix timestamp or it won’t be much good at all.

    Also if you really really do have to fetch it in the way the client wants and you will need to use it in the future then I’d be inclined to write an extension which takes the aggregate date data and converts it into a timestamp using the php strtotime function so that you get the correct data stored and also you aren’t reliant upon javascript being turned on in order for this to work.

    Best wishes,

    Mark

  • #6 / Feb 24, 2011 11:16pm

    aircrash

    293 posts

    There’s actually a thread about a javascript solution on the safecracker support forum: http://barrettnewton.com/forums/viewthread/1271/

    Mark, to answer your question about why, in my case I’m building a reservation system where the date is selected by clicking a link on a calendar, which loads the SAEF. Once on the SAEF page, the user needs to be able to choose an appointment time from a dropdown. I need to be able to restrict the time to a pre-defined selection, so the regular datepicker is just too flexible for this situation.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases