• Resolved mitsakos999

    (@mitsakos999)


    Hello,
    I would like to know please if there is any way to have a select dropdown for the subject field.
    Thank you in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Codeinwp

    (@codeinwp)

    Hey @mitsakos999,

    Yes, you can surely do it.

    here you have the code snippet which you can use to achieve this:

    
    add_filter( 'pirate_forms_public_controls', 'pf_add_subject_dropdown' );
    function pf_add_subject_dropdown( $elements ) {
    	foreach ( $elements as $key => $element ) {
    		if ( $element['id'] === 'pirate-forms-contact-subject' ) {
    			$elements[ $key ]['type']    = 'select';
    			$elements[ $key ]['options'] = array(
    				'My subject option 1' => 'My subject option 1',
    				'My subject option 2' => 'My subject option 2',
    				'My subject option 3' => 'My subject option 3'
    			);
    		}
    	}
    
    	return $elements; 
    }

    Obviously you need to replace the select option with your values.

    Thank you for your fast answer, it works great
    Is there any way to make the first option something like a placeholder, or not a valid option..so the user will have to select some of the remaining choices ?
    I m marking this as resolved 🙂
    Great support

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dropdown subject’ is closed to new replies.