PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Custom field did not save after execution of gform_pre_submission action

  1. brubrant2
    Member

    Hello all! I just found this topic related to my issue but did not help me much http://www.gravityhelp.com/forums/topic/date-field-to-custom-post-date-field-problem-from-date-to-unix

    I've a form configured to create a new custom post type object [saveAsCPT] => desafio

    In this form I've a date field [type] => post_custom_field to save a [postCustomFieldName] => data_limite http://pastie.org/6451207

    I hooked a function in gform_pre_submission_6 action http://pastie.org/6451516 to convert field date to format that I need http://pastie.org/6451625

    But when submitted the form, the custom field data_limite is not created to the new post.

    When the function la_convert_field_date isn't executed in gform_pre_submission_6 hook then the custom field is saved.

    Thanks in advance for any help!

    Posted 6 years ago on Monday March 11, 2013 | Permalink
  2. David Peralty
    Administrator

    Can you help me understand better please.

    1.) You have a date field in your form and it is collecting the date correctly?
    2.) You want to take that date and put it in a custom field?
    3.) Did you create another field to put the date/time into after you've converted it the way you want?
    4.) Can you lay out how you want the date to look in the custom field?

    Posted 6 years ago on Monday March 11, 2013 | Permalink
  3. brubrant2
    Member

    1) Yes, correctly. Field properties: http://pastie.org/6451207

    2) Yes. If I do not call my function in hook gform_pre_submission then the custom field is updated with the value of the date field correctly. As I need change the format of date I executed my function la_convert_field_date, but after that the custom field isn't updated anymore.

    http://pastie.org/6451516

    3) No. I stored in the same variable $ _POST['input_3'] : http://pastie.org/6451625.
    Isn't this variable $ _POST['input_3'] that will be stored in date field ([id] => 3)?

    4) In "YYYY-MM-DD HH:MM:SS" format.

    Thanks David.

    Posted 6 years ago on Monday March 11, 2013 | Permalink
  4. David Peralty
    Administrator

    You can't change how the data is stored in that field. You'll have to store it in another field. I recommend just a hidden input field. Then it won't try to stop you from making the changes you want to the data and saving it to the database. Our date fields are locked in terms of how the data is stored.

    Posted 6 years ago on Monday March 11, 2013 | Permalink
  5. brubrant2
    Member

    Got it! Thanks a lot for your support David. Regards.

    Posted 6 years ago on Monday March 11, 2013 | Permalink

This topic has been resolved and has been closed to new replies.