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.

Terms and Conditions Text - Record in Form Entries database

  1. In creating a form that contains Terms and Conditions, I have placed the T&C text in a Section Break field, in the contents.
    It displays fine on the form.

    The issue is - when the user submits the form, I want all fields they filled out (like normal), AND the T&C text to be placed into the Entries database.

    Currently, when they complete the form, the Section Break Title ('Terms' in my case) is returned to the Entries database, but not the 'content' of the Section Break field, which is where I actually have the T&C text placed.

    The reason that I need this is that in reality, if I do not have the T&C text in the Entries database, I can't prove what they agreed to on the form.

    Another solution that I read in another post is to create a Paragraph field, with Default Text, and place my T&C text there. The problem with this method is that the user can MODIFY the text in the paragraph field, thereby providing a chance that they might alter the Terms (and we would not catch it).

    Is there a way to do this?

    Posted 12 years ago on Monday May 9, 2011 | Permalink
  2. Lee Hord
    Member

    I think you would definitely need to go down the paragraph field route but make it read only. You could use something like this:

    http://www.gravityhelp.com/forums/topic/disabled-fields#post-20592

    Posted 12 years ago on Monday May 9, 2011 | Permalink
  3. Hi Lee,
    I placed the code

    if ($("li.gf_readonly")){ $("li.gf_readonly input").attr("readonly","readonly"); }

    in my footer.php file, right above wp_footer();
    Then added the gf_readonly class to my paragraph field.
    I was still able to edit the paragraph text...
    What am I doing wrong?

    Posted 12 years ago on Monday May 9, 2011 | Permalink
  4. Lee Hord
    Member

    Apologies, should have stated that you need to change input to textarea in my code e.g.

    if ($("li.gf_readonly")){ $("li.gf_readonly textarea").attr("readonly","readonly"); }
    Posted 12 years ago on Monday May 9, 2011 | Permalink
  5. Lee,
    Hmmmm.... still not working.
    I changed it to

    if ($("li.gf_readonly")){ $("li.gf_readonly textarea").attr("readonly","readonly"); }

    It is directly above

    <?php wp_footer() ?>

    in my footer.php file. Using WordPress 3.1.2

    I was still able to edit the text in the paragraph field of the form.
    I must be missing something.

    Posted 12 years ago on Monday May 9, 2011 | Permalink
  6. Anybody?

    Posted 12 years ago on Monday May 9, 2011 | Permalink
  7. You would have to post a link where we could see your form and inspect both the HTML and any custom jQuery you have implemented so we can see what is being done and what needs to change.

    Posted 12 years ago on Monday May 9, 2011 | Permalink
  8. Hi Carl,

    Here is a link to the form

    I have this in the header.php file:

    [html]
    <br />
    <script type="text/javascript"><br />
    		jQuery(document).ready(function($){<br />
    			if ($("li.gf_readonly")){ $("li.gf_readonly textarea").attr("readonly","readonly"); }<br />
    		}<br />
    </script><br />

    Thanks much for your help

    Posted 12 years ago on Monday May 9, 2011 | Permalink
  9. Had an error on Firebug console.
    Changed header.php to

    jQuery(document).ready(function($){
    if ($("li.gf_readonly")){ $("li.gf_readonly textarea").attr("readonly","readonly"); }
    });

    Still not working...

    Posted 12 years ago on Monday May 9, 2011 | Permalink
  10. Lee Hord
    Member

    Hmmm, strange it works for me. However there is one thing you could try, change your code to this to see if it makes any difference, I think you may be having a JQuery conflict issue given the errors shown in the console.

    if (jQuery("li.gf_readonly")){
        	jQuery("li.gf_readonly textarea").attr("readonly","readonly");
    }
    Posted 12 years ago on Tuesday May 10, 2011 | Permalink
  11. Hi Lee,
    I have this code in header.php:

    <script>
    if (jQuery("li.gf_readonly")){
        	jQuery("li.gf_readonly textarea").attr("readonly","readonly");
    }
    </script>

    If the paragraph field is readonly, it should not have a scroll bar on the right, correct? I tested it and it still lets me alter the text.

    Now I'm getting this error in the FB console:
    jQuery is not defined
    Line 12

    Line 12 is your code...

    Posted 12 years ago on Tuesday May 10, 2011 | Permalink
  12. The problem is most likely due to the fact your custom jQuery is loading before jQuery is being included on the page. This custom jQuery relies on the jQuery library in order to load. Your code sits higher up in the code than the jQuery script load itself which is most likely why it isn't working and is giving you a "jQuery is not defined" error message.

    Make a custom page template for your form page and move that custom jQuery code to set the field to readonly into the page template itself and not in the header. Then use that page template for your form page. This way that code also only executes for that page, because it shouldn't execute on every page... you'd get a javascript error if it tries to execute on a page where those elements don't exist.

    The problem is the order in which the code is executing, how you have it setup right now it isn't going to work.

    Posted 12 years ago on Tuesday May 10, 2011 | Permalink
  13. Hi Carl,
    Ok, I did what you suggested. But still not working...

    I can't believe that there isn't an easier solution to this (returning text to the database)?

    Posted 12 years ago on Tuesday May 10, 2011 | Permalink
  14. Hi Munman,

    This might simplify things for you.

    1. Remove the script you've added to the header.php.
    2. Open up functions.php
    3. Paste the following at the bottom of the file: http://pastie.org/1886118
    4. In the pasted code, replace the '1' with the ID of your form. You can get the form ID from the form list page.

    That should automatically add the script for you after jQuery has loaded and has the added benefit of only loading on pages that have this form.

    Posted 12 years ago on Tuesday May 10, 2011 | Permalink
  15. Hi David,
    That code didn't work.
    Got parse errors. Removed php tags, then got an error on this line:

    <script type="text/javascript">

    Not expecting <

    Any ideas?

    Posted 12 years ago on Tuesday May 10, 2011 | Permalink
  16. Try this: http://pastie.org/pastes/1886240/text

    Make sure you do not remove any of the <?php ?> tags.

    Posted 12 years ago on Tuesday May 10, 2011 | Permalink
  17. David -
    That worked!
    THIS should be in the documentation somewhere?
    It would be nice if there was a new feature in future release that would enable an easy option to make a field readonly?

    Last question - since this is a paragraph text field, there is a scroll bar on the right when displaying the form. Not a big deal, but in my case, I would just as soon display all or the text, with no scroll.
    Is this possible?

    Thanks again for your help!

    Posted 12 years ago on Wednesday May 11, 2011 | Permalink
  18. Hi Munman,

    This topic has been added to the list of helpful forum topics in the documentation:

    http://www.gravityhelp.com/documentation/page/How_To#Helpful_Snippets_and_Forum_Topics

    In regards to ditching the scroll bar, you can use CSS to adjust the height of the field so that it is tall enough that no scroll bar is required.

    Posted 12 years ago on Friday May 13, 2011 | Permalink
  19. FanaticWeb
    Member

    Guys, What about single lined text fields or pre-selected checkboxes? I'm trying to apply this code from my end on single lined pre-populated username and email fields for logged in users but its not working.

    Can you pretty please implement this option in the future?? a simple checkbox next to the field indicating it would be "Read-only" would do it.

    Common case scenarios for this feature would be:
    Blog using a the GF Registration add-on, Users create their profiles and log in, pending on their roles, they can post articles to the blog, hence when submitting the post, the Username and Email field would be pre-populated using the "Default Value : Insert variable" approach and right there, a Read-only checkbox can make life easier to block the field from being edited.

    Just a friendly suggestion for the non-programmers out there :)

    Posted 12 years ago on Saturday July 2, 2011 | Permalink
  20. Ok, I've got a slight problem with this. It doesn't work on a multi-page form.

    I've got a 5 page form (so far), and on the 5th page, I wanted to display some Terms & Conditions, but I could not for the life of me get this to work. So in preparation to post here, I put a textarea on the first page of the form so you wouldn't have to go through all pages, but the funny part is, the new textarea on the first page is not editable whereas on the 5th page it is. Both have the CSS class of gf_readonly.

    http://mouthhorse.wokabout.net/apply

    I've un-required all the fields so you should just be able to click through to get to the last page to see for yourself. Any help or pointers would be appreciated. Oh, and I've gone the route of adding the function to my functions.php, but I've tried the other routes as well i.e. adding to header.php, footer.php.

    Posted 12 years ago on Thursday November 17, 2011 | Permalink
  21. You can easily implement this for input fields by changing this line in the code:
    jQuery("li.gf_readonly input").attr("readonly","readonly");

    Make sure under Advanced -> you add the css class of gf_readonly to each input you would like as read only....

    That's my 2 cents and works like a charm following the instructions above.

    Posted 12 years ago on Thursday November 17, 2011 | Permalink
  22. Thanks, but you should read my post in it's entirety, flauntbooks. But just to rehash,

    I am implementing this code in my functions.php to make a textarea field read only. It works on a textarea on the first page of my multi-page form (put there just for example), but not on the 5th page, where I want the actual read only textarea. Both textareas have the class gf_readonly. Visit the url to have a look.

    http://mouthhorse.wokabout.net/apply

    Posted 12 years ago on Thursday November 17, 2011 | Permalink
  23. This is because of how multi-page forms work. Your code isn't going to trigger on every page load. You have to tell it to do so. There is a jQuery hook you can use to do this that triggers code on each page load in a multi-page form. Documentation for it is here:

    http://www.gravityhelp.com/documentation/page/Gform_page_loaded

    Posted 12 years ago on Thursday November 17, 2011 | Permalink
  24. Thanks for that, it works like it should now. Seeing as I had to take the function out of my functions.php and load the actual script on the page, I created a page template to used just by this form, so it works great. Thanks for help!

    Posted 12 years ago on Saturday November 19, 2011 | Permalink
  25. Great. Thank you for the update.

    Posted 12 years ago on Saturday November 19, 2011 | Permalink

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