This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

Populating date field by URL


  1. vandar
    Member

    I have PHP code that queries three different mysql databases, including the machform database, and then generates a URL to populate the form by the user inputting a numerical key. It is stated that some fields do not accept URL population and that this is not supported, specifically the date field, but this happens to be very important for my form.

    The problem is that I cannot trust user input to even approximate a properly formatted date, but I like the javascript datepicker, but the form needs to be able to be populated from the mysql databases.

    How can I preserve the datepicker and formatting constraints for the date field but have an element that accepts population by URL? It could just be a single text or number field with a datepicker, but I don't know how to make that work. If someone could at least point me in the general direction, I would appreciate it. Thank you.

    Posted 12 years ago #
  2. yuniar

    Actually the date field can be populated using URL parameters, as described here:
    http://www.appnitro.com/doc-url-parameters

    What version of MachForm do you use? You will need to use at least version 3.2
    Using the above, you can populate the date field and not to worry about the format. Since the PHP script will validate it when the form is being submitted.


    MachForm Founder

    Posted 12 years ago #
  3. vandar
    Member

    Thanks. I feel both better and stupid for there really being no problem in the first place, so the problem must be with my code. I am using version 3.3.

    All the other elements are working in the URL except time fields.
    Can &element_1=2012-09-24 ,for example, be an acceptable part of the URL? The cell is being queried directly from the machform database.

    I realize now that the date and time input is three sub-elements on the form, but the date and time values are single values in the database. I will have to work around that myself to accomplish what I need. Thank you again.

    Posted 12 years ago #
  4. vandar
    Member

    I just had to adjust my mysql query with a date format function and three aliases per date, like:

    SELECT DATE_FORMAT(element_36,'%m') AS element_36_1, and so on

    Posted 12 years ago #

RSS feed for this topic

Reply