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.

Unable to save selected values from checkboxes field in database

  1. mikc03
    Member

    Hi,

    I'm using the Registration add-on to create a registration form.
    My registration form includes a checkboxes field that I want to dynamically populate from a heirarchical taxonomy.
    And I want the checkboxes to be displayed in the form in a heirarchical format

      Parent Term 1

    • child term 1.1
    • child term 1.2
      parent term 2

    • child term 2.1
    • child term 2.2
      child term 2.3
      parent term 3

    • child term 3.1

    What hooks should be using to this? I want to be able to populate the checkboxes and display them in a heirarchical way and in html columns.

    I tried gform_field_content so that I can replace the content of the checkboxes field with html tags that I can style. I was able to display the checkboxes in the format I wanted.

    But, whenever I submit the form, the selected checkboxes are lost and the validation complains that I did not select any checkboxes (it is a required field).
    Also, if I make this field not required, select few checkboxes and submit the form, the selected values from the checkboxes are not saved in the database.

    Could you please help me figure out this issue? I'm unable to move forward with this. I have been struggling with this for the last 2 days.

    Thank you,
    RB

    Posted 11 years ago on Monday January 28, 2013 | Permalink
  2. Do you have a link to this form online and can you share the custom code you are using now? Please use pastebin.com or pastie.org to share your code, and share the URL to the page on your site where the form is embedded. Thank you.

    Posted 11 years ago on Monday January 28, 2013 | Permalink
  3. mikc03
    Member

    I do not have a link to the form online. I'm developing on my machine.

    Here is the code for my callback function on gform_field_content hook : http://pastebin.com/cBZLDBVV

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink
  4. I'll bring this topic to the attention of the development team. Thanks for sharing the code.

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink
  5. mikc03
    Member

    Thanks Chris.

    Please let me know how soon will the development team take look at this. I'm really stuck here and can't move forword as I'm not able to complete the user registration with all the needed fields.

    I just need to know if my approach is correct or not. If I'm doing it wrong, what is the best way to dynamically populate heirarchical checkboxes that are included in the registration form? and how to change the html structure of the checkboxes in order to be able to display/style them in a heirarvhical format in the form?

    Some code snippets, if possible, would be great.

    Note: I do not see the Checkboxes in the Registration Add-on feed page, where the gravity form fields are mapped to wordpress fields. So I'm not able to map the checkboxes field. How do you map checkboxes? could this be the problem?
    Under the custom fields section, I added my custom field "custom categories", but in the matching dropdown on the right side, I do not see/know what field I shold map it to.

    Thank you very much,
    RB

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink
  6. Checkboxes are surprisingly difficult fields to develop and manage, and what you are trying to do with them (dynamically populating them hierarchically) makes this even more complex. When you take that combination and try to then integrate it to the User Registration Add-On, I say it's too complex to tackle. I would have to spend hours trying to figure out what to do, and I am very familiar with Gravity Forms. What I suggest is that you take a different approach, using fields that are easier to manage such as radio buttons or drop downs. I understand it is not ideal, but I do think you will be banging your head against the wall trying to get this custom checkbox to work.

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink
  7. mikc03
    Member

    Thanks Alex,

    Could you please let me know how to map checkboxes in the User Registration feed?
    I do not see the Checkboxes in the User Registration feed page, where the gravity form fields are mapped to wordpress fields. So I'm not able to map the checkboxes field.

    Thanks for your help,
    RB

    Posted 11 years ago on Tuesday January 29, 2013 | Permalink
  8. mikc03
    Member

    Hi,

    The User Registration Add-on is one of the main reasons why I bought the Developer License of Gravity forms.

    But now, I'm stuck here and I can't finish the registration.

    I have to implement this functionality. And I have to do it using heirarchical checkboxes. I do not mind working on this for hours or even days, as long as I know I'm using the correct hooks and going in the right direction.

    So I just need any help or direction you guys can give me.

    Also, I might have found a way to implement this. One thing I still do not know is: What is the best way to update the created entry (in database) after the user submits the registartion form? I want to add other attributes to the entry after submission and save them to the database. And be able to retrieve the new attributes from the entry later.

    Thanks for your help,
    RB

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink
  9. mikc03
    Member

    Just FYI,

    While I was looking at the wp_rg_lead_detail table to figure out how to insert new attributes for the entry (lead), I noticed that the field_number is a float data type.

    There is a problem with that. If the field_number is 5.10, when it's stored in the databse, the trailing 0 is removed. So what is stored in the database is 5.1

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink
  10. The code in most places for checkboxes skips the multiples of ten when indexing, so you would go from 9 to 11. See form_display.php, (around line 188 in my version):

    [php]
    if($index % 10 == 0) //hack to skip numbers ending in 0. so that 5.1 doesn't conflict with 5.10

    So, that is by design.

    Posted 11 years ago on Thursday January 31, 2013 | Permalink
  11. Regarding this:

    What is the best way to update the created entry (in database) after the user submits the registartion form?

    You will have to update the database directly, with a function hooked to gform_user_created maybe. Here is code I provided a while back, to update an entry with information which was not available at the time the form was submitted: http://pastebin.com/8jzCnSpK

    Posted 11 years ago on Thursday January 31, 2013 | Permalink
  12. mikc03
    Member

    Thanks Chris, I really appreciate your help.

    That's exacly what I ended up doing. I skipped multiples of 10. It's a hack, but it works :).

    Your sugested code for updating the entry is good. That's what I ended up doing as well.

    Thank your very much for following up on this.

    Have a great day!
    RB

    Posted 11 years ago on Thursday January 31, 2013 | Permalink
  13. No problem. Thank you for the update.

    Posted 11 years ago on Friday February 1, 2013 | Permalink

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