I’m having a problem with setting the required attribute on multiple choice elements via PHP.
What I have are three multiple choice elements contained in a group that is initially hidden on load via JS. I have two checkboxes: If I click on the 2nd checkbox, the hidden group is displayed.
The required attribute should be applied to the multiple choice elements if the 2nd checkbox is checked and vice versa.
I’m using the code below to set the attribute, but somehow I couldn’t get it to work
function my_set_fields_required($form) { if ($form->getValue('iphorm_177_72_2') == 'Ex-U.S. stock markets') { $form->getElement('iphorm_177_73')->setRequired(true); $form->getElement('iphorm_177_76')->setRequired(true); $form->getElement('iphorm_177_77')->setRequired(true); } } add_action('iphorm_pre_process_177', 'my_set_fields_required');