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

Logic Builder condition for date field relative to current date


  1. timcov
    Member

    I very new to the MachForm but it is fantastic. I can't believe I've been wasting so much time messing with the hosted solutions such as the numerous online survey builders etc. Complete control over the data at last!
    Anyhow quick question - I can set the default for a date field for "tomorrow" or "+2 days" (surprisingly simple) but that doesn't work in the logic builder which seems to need specific dates. Is there a notation to use to achieve skipping a page unless the value of a date field is tomorrow for example?
    Thanks for a great product.

    Posted 8 years ago #
  2. yuniar

    Hi timcov,

    Unfortunately it won't be possible to set relative date as part of the rule. Sorry :(
    Thank you for your feedback on this though. It's a very good idea.


    MachForm Founder

    Posted 8 years ago #
  3. timcov
    Member

    Thank you for the prompt response
    However needing to overcome this for a particular application and not wishing to give up - is it worth my while either:
    a) looking for the php code that applies the rule and trying to "hard code" that rule instead? or
    b) create a cronjob to run a linux job on my hosting each morning that takes today's date, adds 1 to it and then updates the rule in the MySQL table: ap_field_logic_conditions accordingly?

    I appreciate both would be crude solutions but I'm reluctant to ask the administrator to login each morning and change the rule to tomorrows date.

    Option b) is perhaps safest as I only follow enough about php coding to find relevant sections of existing code and make simple tweaks. At least with b) I'm only trying to update one field in one record of the database with a text format of the system date and am not trying to change the code itself?

    Thanks Again

    Posted 8 years ago #
  4. yuniar

    If you are familiar with cron job, then yes option B would be the safest and cleanest, because it won't affect any other functionality. Simply update the "rule_keyword" column on "ap_field_logic_conditions" table.


    MachForm Founder

    Posted 8 years ago #
  5. timcov
    Member

    Many Thanks Yuniar - it works. For anyone that needs it the sql query I used to reset the day in the condition to "the day after tomorrow" was:

    $sql = "UPDATE my_dbase_name.ap_field_logic_conditions SET rule_keyword = DATE_ADD(CURRENT_DATE(),INTERVAL 2 DAY) WHERE form_id =12345 AND rule_condition = 'is_before'";

    MySql Event Scheduler would be a better way to run it regularly but my shared hosting doesn't seem to allow me to enable it.

    Posted 8 years ago #
  6. yuniar

    awesome! :-)


    MachForm Founder

    Posted 8 years ago #
  7. jrmedia
    Member

    This is a great idea for something such as an "age of majority" checker, to have the person enter their date of birth and display additional information (such as parent/guardian information).

    I'm looking at this thread and the code makes no sense to me (I'm a designer, not a developer).

    What do I need to do to implement the fix shown here?

    Posted 8 years ago #

RSS feed for this topic

Reply