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.

List Item (Multiple Columns) With Dropdown

  1. Anonymous
    Unregistered

    Hello..

    We have a list item with three columns. We'd like to be able to add a fourth column with a dropdown select box instead of a text box. How can this happen?

    Or at least the same functionality a different way if it cannot be done through a multi-column list field.

    Posted 11 years ago on Wednesday February 13, 2013 | Permalink
  2. Richard Vav
    Administrator

    What you want to do is add the fourth column to your field and add the following code to your themes functions.php file between the opening and closing php tags. Change 187 to match your form number and 1 to match your field number, 4 is the column number.

    add_filter("gform_column_input_187_1_4", "set_column", 10, 5);
    function set_column($input_info, $field, $column, $value, $form_id){
        return array("type" => "select", "choices" => "First Choice,Second Choice");
    }

    You can find out more about this filter by checking out the following page of the documentation, http://www.gravityhelp.com/documentation/page/Gform_column_input

    Posted 11 years ago on Thursday February 14, 2013 | Permalink
  3. Thanks again Richard. We appreciate your posts.

    Posted 11 years ago on Monday February 18, 2013 | Permalink
  4. How hard would it be to have a date field instead of text?

    Posted 11 years ago on Tuesday March 5, 2013 | Permalink
  5. Richard Vav
    Administrator

    Edit: 13/9/13

    There is now a demo of adding a datepicker to a list field column over at http://gravity.wawrzyniak.me/list-field-with-datepicker/


    Using the gform_column_input_content filter the list field can now use different input types such as text fields, http://www.gravityhelp.com/documentation/page/Gform_column_input_content

    I haven't tried this so I have no idea if it would work but in theory you could use something like this to change the column to a date field

    add_filter("gform_column_input_content_21_9_3", "change_column3_content", 10, 6);
    function change_column3_content($input, $input_info, $field, $text, $value, $form_id){
    //build field name, must match List field syntax to be processed correctly
    $input_field_name = 'input_' . $field["id"] . '[]';
    $tabindex = GFCommon::get_tabindex();
    $new_input = '<input name="' . $input_field_name . '" ' . $tabindex . ' class="datepicker medium mdy datepicker_no_icon hasDatepicker" >';
    return $new_input;
    }

    The hard part is going to be activating the datepicker ui on the dynamically added rows, which I think would require use of the jquery .on method.

    Posted 11 years ago on Tuesday March 5, 2013 | Permalink
  6. maadmaxx
    Member

    Hey Richard,

    I've successfully added Radio Buttons using gform_column_input_content, however when I hit Add New Row (+), the selected radio button, moves to the second row, and the first row deselects, as if they are part of the same group.

    http://pastebin.com/DiUi4V86

    Also, what do the parameters , 10, 6) do?

    Posted 11 years ago on Thursday July 11, 2013 | Permalink
  7. Richard Vav
    Administrator

    @maadmaxx I will take a look at your code and see what we can come up with.

    You can find out about the add_action and add_filter hooks in the wordpress.org codex, but 10 refers to the priority for the order in which the actions/filters associated function should be executed and 6 refers to the number of arguments the function accepts.

    Edit: responded further in your other post http://www.gravityhelp.com/forums/topic/radio-buttons-in-gform_column_input_content-list?replies=2#post-375978

    Posted 11 years ago on Thursday July 11, 2013 | Permalink

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