妥当性検査ルールの選択に関する質問があります。ルールセットからルールを除外する方法
は、私はそのように
public $validate = array(
'sentence_fields'=> array(
'select_chapter' => array(
'field'=>'select_chapter',
'label'=>'Select chapter',
'rules'=>'required|integer'
),
'source_sentence' => array(
'field'=>'source_sentence',
'label'=>'Source',
'rules'=>'trim|required|max_length[500]'
),
'translated_sentence' => array(
'field'=>'translated_sentence',
'label'=>'Translation',
'rules'=>'trim|required|max_length[500]'
),
'translated_translation' => array(
'field'=>'translated_translation[]',
'label'=>'Select another translation',
'rules'=>'trim|max_length[500]'
)
)
);
のようなモデルで私の検証ルールを固執作成方法のためだったので
$validate = $this->sentence_model->validate['sentence_fields'];
$this->form_validation->set_rules($validate);
のようなコントローラでそれを呼び出すが、私はupdateメソッドを持っていますselect_chapter
のルールセットは必要ありません。
このルールセット(sentence_fields)を呼び出す簡単な方法はありますか?私の更新方法はselect_chapter
を除外しますか?
ありがとうございました。
こんにちは、私はこれがどのように動作するかを理解しますが、何らかの理由で、私はまだ取得しています次の出力の章配列を選択してください。 '$ validate = $ this-> sentence_model-> validate ['sentence_fields']; unset($ validate ['sentence_fields'] ['select_chapter']); print_r($ validate); ' 明らかに間違っているものはありますか?ありがとう。 – user3442612
はい、 '$ validate ['sentence_fields'] ['select_chapter']'の各キーを解除する必要があります。 –
'unset($ validate ['select_chapter']);' '$ validate 'に' sentence_fields'を割り当てたように見えます – user3442612