跳过moodle中禁用字段的验证

时间:2016-11-23 11:20:00

标签: validation moodle

当我点击是单选按钮时,应该需要复选框,如果没有,那么它不应该验证复选框。目前它在两种条件下都有效,我只想在选择是单选按钮时才需要验证。 这是图像enter image description here

    $confirmpreprocedure[] = $mform->createElement('radio', 'preprocedure4', '', get_string('yes','assignsubmission_ebus'), 'yes');
    $confirmpreprocedure[] = $mform->createElement('radio', 'preprocedure4', '', get_string('no','assignsubmission_ebus'), 'no');
    $mform->addGroup($confirmpreprocedure, 'preprocedure4', get_string('preprocedure','assignsubmission_ebus'),array(' '), false);
    $mform->addRule('preprocedure4', null, 'required', null, 'client');

    $mform->disabledIf('preprocedure', 'preprocedure4', 'neq', 'yes');


    $preprocedure   = array();
    $preprocedure[] =  $mform->createElement('advcheckbox','preprocedure1',get_string('pet','assignsubmission_ebus'),'PET','',array('','PET'));
    $preprocedure[] =  $mform->createElement('advcheckbox','preprocedure2',get_string('contrastct','assignsubmission_ebus'),'Contrast CT','',array('','Contrast CT'));
    $preprocedure[] =  $mform->createElement('advcheckbox','preprocedure3',get_string('ldct','assignsubmission_ebus'),'Low dose CT','',array('', 'Low dose CT'));

    $mform->addGroup($preprocedure,"preprocedure",'if Yes',array('<br>'), false);

    $mform->addRule('preprocedure', null, 'required', null, 'client'); 

1 个答案:

答案 0 :(得分:0)

您是否尝试过移动disabledIf行,以便它位于您要添加要禁用的组的行之后?我还没有对它进行过测试,但这种情况似乎总是如此。