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.

making post image title required

  1. sascha
    Member

    Hi again,
    is there a way to make the "title" field of an "post image field" a required field?

    Posted 12 years ago on Monday December 5, 2011 | Permalink
  2. There is a required checkbox for the post title field. Does that not work? I've never tried it without entering a title, when it was checked as required.

    Posted 12 years ago on Monday December 5, 2011 | Permalink
  3. sascha
    Member

    Hi Chris,
    I do not mean the "post title". Sorry! I mean the "post image field". Under post images you have the option of letting users enter a title, caption and description.

    When title is ticked, it shows the user a title sub-field. How can I make this sub-field required?

    Posted 12 years ago on Monday December 5, 2011 | Permalink
  4. Hi sascha, sorry about that. I misread it the first time around. I will find out for you. If it's not possible, you might be able to do it with another field in the form, just a text field, called "Image Title" and make that required. Then, in your content template, use that field as the title attribute of the img tag. Would that work?

    Posted 12 years ago on Wednesday December 7, 2011 | Permalink
  5. sascha
    Member

    HI Chris,
    Not sure if that would work with the content template. I need the uploaded image to have that information in the title also when I go to my wordpress backend. Other plugins/functions display the title. so it must be available.

    Could I use the gform_after_submission hook to add the title from that new field to the attachment data? Not sure how to do this though.

    Posted 12 years ago on Wednesday December 7, 2011 | Permalink
  6. sascha
    Member

    Hi again,
    or even better could the title/caption/description fields be made to be populated dynamically or have a content template? Then I could generate those from other fields in the form...

    Posted 12 years ago on Wednesday December 7, 2011 | Permalink
  7. The post image field doesn't support the content template functionality.

    In order to do what you want to do you'd have to write custom validation using the gform_validation hook to make the Post Image Title field required.

    Here is a tutorial on how to use the gform_validation hook to create custom validation:

    http://www.gravityhelp.com/documentation/page/Using_the_Gravity_Forms_%22gform_validation%22_Hook

    Posted 12 years ago on Wednesday December 7, 2011 | Permalink
  8. sascha
    Member

    Thanks Carl,
    Ok, I will look into that. Good idea to do a custom validation! How will I be able to set required class at the same time? Jquery? Would you know how?

    Posted 12 years ago on Thursday December 8, 2011 | Permalink
  9. Hi sascha, take a look at this solution posted by Alex:

    http://www.gravityhelp.com/forums/topic/bug-gform_pre_render-isrequired-does-not-work-for-fileupload-fields#post-38750

    You would add code to your theme's functions.php making it required and forcing the validation to know it's required as well.

    Posted 12 years ago on Saturday December 10, 2011 | Permalink