0
如何添加text
字段所需的規則Moodle。addRule for Moodle中的文本字段組
for ($i = 1; $i <= 4; $i++) {
$ansgroup = array(
$mform->createElement('radio', 'answercorrect', '', '', $i, array('class' => "mock_answerradio", 'id' => "rad$i")),
$mform->createElement('text', "answertext[$i]", '', array('size' => 30, 'id' => "text$i")),
);
$mform->addGroup($ansgroup, 'answer', 'Option-' . $i, array(' '), false);
$mform->addRule('answertext[$i]', null, 'required', null, 'client'); //not working
$mform->setType("answertext[$i]", PARAM_RAW);
}
我必須把addRule
爲text
領域。但沒有運氣。 我想是這樣的:
$mform->addRule('answertext[1]', null, 'required', null, 'client'); //not working