cancel
最初は、 のボタンを使用しませんmoodle form
。私のフォームは次のようになります。
require_once("{$CFG->libdir}/formslib.php");
class quest_form extends moodleform {
function definition() {
global $DB;
$mform =&$this->_form;
$mform->addElement('header','displayinfo', 'Add Question');
// add question.
$mform->addElement('editor', 'title', 'Question');
$mform->addRule('title', null, 'required', null, 'client');
$mform->setType('title', PARAM_RAW);
// add answer.
$mform->addElement('editor', 'answer', 'Answer');
$mform->addRule('answer', null, 'required', null, 'client');
$mform->setType('answer', PARAM_RAW);
$mform->addElement('hidden', 'blockid');
$mform->setType('blockid', PARAM_RAW);
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_RAW);
$this->add_action_buttons(false, 'submit');
}
フォームでボタンを使用したいcancel
ので、行を置き換えます
$this->add_action_buttons(false, 'submit');
と
$this->add_action_buttons(true, 'submit');
cancel
ボタンは正常に表示されますが、ボタンをクリックしている間(cancel
フォームthe form gets submitted
フィールドにデータがない場合でも)。
どうすればこれを解決できますか? 私は他に何かが恋しいですか??
私を助けてください...
編集
ラッセル・イングランドの回答次第。私は以下のように試します:
$qform = new quest_form ();
if ($qform ->is_cancelled()){
redirect("view.php?id={$cid}");
}else{
$qform = new pool_form("pool_action.php?id={$cid}&qpid={$questplace->id}&qtype={$qtype}");
}
$qform ->display();
それでもcancel button
フォームを送信します。