WordPress.org

Ready to get started?Download WordPress

Forums

Gravity Forms + Custom Post Types
Dropdown pre selected option for custom taxonomy (14 posts)

  1. Geet Jacobs
    Member
    Posted 2 years ago #

    In gravity forms you can select a default open for a dropdown which works on normal dropdown fields, but if I "Populate with a Taxonomy" and then check a default option, after saving the form it resets to the default option.

    My goal is for my client to be able to pick a custom taxonomy as default and make the field an admin only field to populate a post with that taxonomy without the user needing to select anything.

    "Field Choices
    Add Choices to this field. You can mark each choice as checked by default by using the radio/checkbox fields on the left."

    Thanks!

    http://wordpress.org/extend/plugins/gravity-forms-custom-post-types/

  2. bradvin
    Member
    Plugin Author

    Posted 2 years ago #

    Hi,

    A default for a taxonomy field is not supported in the current version. But this feature is definately on my todo list for the next version

    cheers
    Brad

  3. styledev
    Member
    Posted 2 years ago #

    Brad, just to let you know. When you can't set a "selected" value then conditionals will not work out the gate for say hiding the submit button if dropdown is not "-- select a Taxonomy Term --".

    You should at least set the first item as "selected"

  4. styledev
    Member
    Posted 2 years ago #

    Hey Brad, I went ahead and added the whole feature as I needed it for a project.

    See diff and new file here: https://gist.github.com/2402893

    @Geet Jacobs - You can just copy and paste (replace) the whole code into your gfcptaddonbase.php (https://gist.github.com/2402893#file_gfcptaddonbase.php)

  5. bradvin
    Member
    Plugin Author

    Posted 2 years ago #

    Hey styledev

    thanks for that code :)

    I will go through it and incorporate this into the next version

    cheers
    Brad

  6. styledev
    Member
    Posted 2 years ago #

    Anytime, feels good to contribute back to the community :)

  7. Geet Jacobs
    Member
    Posted 2 years ago #

    @styledev,
    Thanks so much, exactly what I needed!

    @brad, Thanks for your time and work on this excellent addon to gravityforms.

  8. styledev
    Member
    Posted 2 years ago #

    I made some updates to my gist code. There was an issue with my $selected code when using Single Line Text with Save to Taxonomy that through an error. This is now accounted for and fixed.

  9. bradvin
    Member
    Plugin Author

    Posted 2 years ago #

    hey guys,

    Please could you test out the new beta version : http://themergency.com/gravity-forms-custom-post-types-v4-beta-testers-wanted/

    @styledev, I included code to take into account the selected items, although my implementation is quite different from yours. Please could you test it out to make sure it works for you.

    thanks for help on this

  10. styledev
    Member
    Posted 2 years ago #

    @bradvin, Everything looks good to me for the "selected items" issue. Great work! I love this plugin :) Any way I can float some money your way?

    One other thing, can you add a away to specify which post statuses you want to display. Currently the plugin only allows Published but for my recent project I needed to show Pending aswell.

    /*
     * Get a hierarchical list of posts
     */
    function load_posts_hierarchical( $post_type ) {
      $args = array(
          'post_type'     => $post_type,
          'numberposts'   => -1,
          'orderby'       => 'title',
          'post_status'   => 'publish,pending'
      );
    
      $args = apply_filters( 'gfcpt_get_post_args', $args );
      $posts = get_posts( $args );
      $posts = apply_filters( 'gfcpt_get_post_filter', $posts );
      return $this->walk_posts( $posts );
    }
  11. bradvin
    Member
    Plugin Author

    Posted 2 years ago #

    @styledev, thanks - you can donate via paypal if you want, but it is not neccessary :) http://themergency.com/donate/

    I think I can add this post_status feature into V4

  12. styledev
    Member
    Posted 2 years ago #

    Awesome and I just donated a little something for you. Keep up the great work!

  13. nickhempsey
    Member
    Posted 2 years ago #

    Awesome work guys, this just saved me a ton of time!

  14. erin814
    Member
    Posted 1 year ago #

    Thanks for this, I just tried it out, works great. Saved me a ton of time!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic