LoginSignup
3
1

More than 5 years have passed since last update.

laravel-admin formでドロップダウンリストから選択する

Posted at

Controllerのformで下記のように記載するとドロップダウンリストで選択した値を入力することができる

$form->select('<カラム名>','値の名前')->options(['設定値' => '設定値名', '設定値' => '設定値名', '設定値' => '設定値名']);

設定例

    protected function form()
    {
        $form = new Form(new Reservations);
        $form->display('id','予約ID');
        $form->display('store_id','店舗ID');
        $form->date('reservation_date','予約年月日');
        $form->time('start_time','開始時間')->format('HH:mm');
        $form->time('end_time','終了時間')->format('HH:mm');
        $form->text('number_of_people','受付人数');
        $form->select('status','予約ステータス')->options(['1' => '予約中', '2' => '来店済', '3' => 'キャンセル']);
        return $form;
    }

検証

下記のように選択できる
ドロップダウンリスト.PNG

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1