LoginSignup
2
0

More than 3 years have passed since last update.

symfonyのchoiceTypeでplaceholderを消す方法(EC-CUBE4)

Posted at

EC-CUBE4では配達日時や時間の初期値として、「選択しない」が選択されている。
しかし、日時を選ばせないのは都合が悪いので「選択しない」をそもそも表示しないようにしてみました。

注文確認画面における配達時間選択画面を生成している部分が以下の通り

$form = $event->getForm();
$form->add(
    'DeliveryTime',
    EntityType::class,
    [
        'label' => 'front.shopping.delivery_time',
        'class' => 'Eccube\Entity\DeliveryTime',
        'choice_label' => 'deliveryTime',
        'choices' => $DeliveryTimes,
        'required' => false,
        'placeholder' => 'common.select__unspecified',
        'mapped' => false,
        'data' => $ShippingDeliveryTime,
    ]
);

これのplaceholderをfalseに変えてあげると、「選択する」というoptionが消せるようになりました。

$form = $event->getForm();
$form->add(
    'DeliveryTime',
    EntityType::class,
    [
        'label' => 'front.shopping.delivery_time',
        'class' => 'Eccube\Entity\DeliveryTime',
        'choice_label' => 'deliveryTime',
        'choices' => $DeliveryTimes,
        'required' => false,
        'placeholder' => false,
        'mapped' => false,
        'data' => $ShippingDeliveryTime,
    ]
);
2
0
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
2
0