Here is the thing.
I have two elements in my module moodle form:
$mform->addElement('selectyesno', 'myconditionalelement', get_string('myconditionalelement', 'ejsapp'));
$mform->addElement('text', 'dependentelement', get_string('dependentelement', 'ejsapp'));
If the user selects "yes" in the first element (myconditionalelement), I would like to use addRule to set the second element as a required param in the form in order to be accepted.
Something like:
if($mform->get_element_value('myconditionalelement') == 1) {
$mform->addRule('dependentelement', null, 'required', null, 'client');
}
I know the previous code is not right, but I think it gives an idea about what I want to do. Is this possible? And if it is, could someone please tell me how to do it?
Thanks!