Support » Plugin: Gravity Forms Directory » GravityForms – List Field with DropDown on entries column

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter nicopulse

    (@nicopulse)

    I found code to populate dropdown, but the question is :
    what is the hook function to display a dropdown instead of simple textbox for a column ?

    The code to populate :

    add_filter('gform_pre_render_5', 'populate_dropdown');
    
    function populate_dropdown() {
    
    	global $wpdb;
    
    	foreach( $form['fields'] as &$field ) {
    
    		// update "populate-dropdown" to dropdown(select) CSS class 
    
    		if($field['type'] != 'select' || strpos($field['cssClass'], 'populate-dropdown') === false)
    
    			continue;
    
    		// our dropdown options
    
    		$choices = array(array('text' => 'Select a Post', 'value' => ' '));
    
    		// select our custom fields
    
    		$posts = $wpdb->get_results( "SELECT ID, btc_state_short FROM btc_state_list" );   
    
    		foreach( $posts as $post ) {
    
    			$choices[] = array('text' => $post->ID, 'value' => $post->btc_state_short);
    
    		}
    
    		$field['choices'] = $choices;
    
    		// if this do nothing, try
    
    		// return $field (uncomment if neeed)
    
    	}
    
    }

    GetWebCreative

    (@getwebcreative)

    Hi @nicopulse, I need to do the same thing. Did you find a way?

    Kyle

    (@kyleheldskybounddesignscom)

    I need also. I wonder if David Smith at Gravity Perks has any snippets?

    The gform_column_input filter should help:

    http://www.gravityhelp.com/documentation/gravity-forms/extending-gravity-forms/hooks/filters/gform_column_input/

    With this filter, you can specify that a particular column should use a drop down rather than an input. Here is the basic code example:

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

    I’ve changed this slightly to more easily identify which numbers in the filter name apply to what. The “187” is the form ID. The “1” is the field ID. And the “2” is the column number. So in this case, the second column would contain selects instead of inputs.

    Kyle

    (@kyleheldskybounddesignscom)

    Fantastic! Thanks spivurno. I spent a few hours on this and you helped me knock it out in about 5 minutes.

    GetWebCreative

    (@getwebcreative)

    @spivurno – thank you so much! You’re a legend! 🙂

    Hey @spivurno, thanks for this code.
    Do you have any idea about file upload field on list field? i tried this code:

    add_filter("gform_column_input_content_8_124_3", "change_column5_content", 10, 6);
    function change_column5_content($input, $input_info, $field, $text, $value, $form_id) {
        $input_field_name = 'input_' . $field["id"] . '[]';
        $tabindex = GFCommon::get_tabindex();
        $new_input = '<input type="file" name="' . $input_field_name . '" ' . $tabindex . ' class="upload" />
        return $new_input;
    }

    this added a file upload button on my 3rd column, i can browse the file and select it. but when i submit form the file are missing. its not uploading at all.

    i know the gravity form uses method <form action="" method="post" enctype="multipart/form-data"> for uploading files, but still dont have idea how to apply.
    would you please help me? i know you are genius and you are the creator of Gravity Perks. I have lot of hooks from Gravity Wiz and i am following you on github.

    If you’re looking for an easy front end managable way to create drop down lists inside list fields, have a look at this plugin

    https://wordpress.org/plugins/gravity-forms-list-field-select-drop-down/screenshots/

    HI,

    add_filter(“gform_column_input_content_1_39_2”, “change_column2_content”, 10, 6);
    function change_column2_content($input, $input_info, $field, $text, $value, $form_id) {
    $input_field_name = ‘input_’ . $field[“id”] . ‘[]’;
    $tabindex = GFCommon::get_tabindex();
    $new_input = ‘<input type=”file” name=”‘ . $input_field_name . ‘” ‘ . $tabindex . ‘ class=”upload” />’;
    return $new_input;
    }

    i have past the code in function.php. the problem is image is not save. can you please help me ?

    @tejpalsoibrandz

    If you’re trying to use a file upload field inside a list field that code is way way way not enough. It’s many multitudes more complicated than simply making the field look like a file upload field.

    You need to hook into the upload, tell it where to save the file (and consider how to make that file as secure and private as possible — which is difficult in WordPress), tell it what files types and sizes you will accept, tell Gravity Forms how to handle the submitted information – how it’s displayed in the submitted form etc etc.

    The good news is, I’ve actually published a plugin that does all this.

    So if you’re wanting to turn a list field into a file upload field – have a look at this plugin instead:

    https://wordpress.org/plugins/ajax-upload-for-gravity-forms/

    Thanks For Reply.

    i have try to install the “Ajax Upload Gravity Forms” but it’s not work.

    I have Try to install this plugin but i am getting error.
    https://wordpress.org/plugins/repeater-add-on-for-gravity-forms/

    ( ! ) Fatal error: Class ‘GF_Field’ not found in
    \wp-content\plugins\repeater-add-on-for-gravity-forms\class-gf-field-repeater.php on line 2
    Call Stack
    # Time Memory Function Location
    1 0.0016 262368 {main}( ) ..\plugins.php:0
    2 1.2044 32136736 plugin_sandbox_scrape( ) ..\plugins.php:164
    3 1.2060 32156464 include( ‘C:\wamp\www\bestdent\wp-content\plugins\repeater-add-on-for-gravity-forms\repeater.php’ ) ..\plugin.php:1964
    4 1.2086 32302320 require_once( ‘C:\wamp\www\bestdent\wp-content\plugins\repeater-add-on-for-gravity-forms\class-gf-field-repeater.php’ ) ..\repeater.php:111

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘GravityForms – List Field with DropDown on entries column’ is closed to new replies.