Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #862106

    So I am using some code in my functions.php file to alter the subject of the email form when sent. I can get it to send just what is selected from the subject dropdown just fine and I can get it to include what is put in the “Other” field. But I haven’t been able to find a solid way to only target the “Other” option from the dropdown/select element so that what is entered into the “Other” text field is only added to the subject ONLY IF the user selects “Other” from the select element. Any ideas?

    Here’s what I have currently…

    // Changes the Enfold form subject
    add_filter('avf_form_subject','avia_change_mail_subject', 10, 3);
    function avia_change_mail_subject($subject, $new_post, $form_params){
    $from_name = urldecode($new_post['1_1']);
    $old_subject = urldecode($new_post['3_1']);
    $subject = $old_subject .' - '. $from_name;
    $other = urldecode($new_post['4_1']);
    	if ($other){
    	return $subject . ' - ' . $other;
    	}
    	else {
    	return $subject;
    	}
    }
    #863131

    Hey Kahil,

    Thank you for using Enfold.

    Please provide a link to the page with the contact form so that we can inspect it.

    Best regards,
    Ismael

    #864149

    There isn’t an issue with the code or the form, I’m just asking if there was a way to disable/enable entry of a text field based on the option chosen in a select box.

    #864408

    Hi,

    What if you check if the $other variable is not empty?

    if ( $other != '' ) {
    

    I’m not sure if that’s what you want but if we can see the contact form, maybe we’ll be able to understand it better.

    Best regards,
    Ismael

    #864429

    Well I don’t care if the other field is empty as it would be unless someone didn’t select “other” from the select box. I think it will involve some JavaScript.

    #865080

    Hi,

    I’m sorry but I don’t understand what you’re trying to do. We would like to inspect the the contact form.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.