Fieldsetのセレクトボックスでオプションを再設定したいときのメモ。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// fieldsetを作成 $fieldset = Fieldset::forge('default'); // セレクトボックスを追加 $fieldset->add('samplebox', 'samplebox label', array('options' => [1 => 'option1', 2 => 'option2'], 'type' => 'select')); // 再設定したいオプション $options_arr = [3 => 'option3', 4 => 'option4']; // オプションを再設定する $fieldset->field('samplebox')->set_options($options_arr , null, false); // この場合、optionは[1 => 'option1', 2 => 'option2', 3 => 'option3', 4 => 'option4'] // オプションを再設定する $fieldset->field('samplebox')->set_options($options_arr , null, true); // この場合、optionは[3 => 'option3', 4 => 'option4'] |
とすれば再設定可能。
◆ 公式
http://fuelphp.jp/docs/1.8/classes/fieldset/field.html#/method_set_options
One comment to this article
Zaiya
on 2016年11月16日 at 9:10 PM -
Great inisthg. Relieved I’m on the same side as you.