Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Conditional Fields and Required attribute not working as intended

$
0
0

Replies: 0

I am using PMPRO with Register Helper add on, I have created a conditional field like this:

$fields[] = new PMProRH_Field(
    'profession',
    'radio', // type of field
    	array(
        'options' =>
            array(
                'Judge' => 'Judge',
                'Attorney' => 'Attorney',
                'Social Worker' => 'Social Worker',
                'Attorney & Social Worker' => 'Attorney & Social Worker',
                'Other' => 'Other'
            ),
        'label'=>'Profession',
        'required'=>true,
	'profile'	=> true,
  	)
    );
	$fields[] = new PMProRH_Field(
            "other_profession",
             "textarea",
              array(
		"depends"=>array(array('id' => "profession", 'value' => "Other")),
		"label"=>"Please Specify Other",
		'profile'	=> true,
        ));

so I need the dependent field(please specify other field) required only if the “other” option selected from the “Profession”. If I give ‘required’=>true to “other_profession”(Please Specify Other) this dependent field will be always be required, and even if I don’t select other option from “Profession” I get required field error when submit the form. Is there any option I am missing, or any work around?


Viewing all articles
Browse latest Browse all 59525

Trending Articles