From c36f469a6ae1c994846a6e1aa68c281df41f656d Mon Sep 17 00:00:00 2001 From: daichi_otani Date: Fri, 3 Mar 2023 09:40:20 +0900 Subject: [PATCH] =?UTF-8?q?feat:=E7=AE=A1=E7=90=86=E7=94=BB=E9=9D=A2>?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=B8=80=E8=A6=A7=E7=94=BB=E9=9D=A2=E3=81=AE?= =?UTF-8?q?=E3=80=8C=E7=99=BB=E9=8C=B2=E6=97=A5=E3=80=8D=E3=80=8C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=A5=E3=80=8D=E6=A4=9C=E7=B4=A2=E3=81=B8=E3=81=AE?= =?UTF-8?q?=E3=83=90=E3=83=AA=E3=83=87=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Form/Type/Admin/SearchProductType.php | 25 +++++++++++++++++++ src/Eccube/Resource/locale/messages.en.yaml | 1 + src/Eccube/Resource/locale/messages.ja.yaml | 1 + 3 files changed, 27 insertions(+) diff --git a/src/Eccube/Form/Type/Admin/SearchProductType.php b/src/Eccube/Form/Type/Admin/SearchProductType.php index a6c22e848e4..66359a54260 100644 --- a/src/Eccube/Form/Type/Admin/SearchProductType.php +++ b/src/Eccube/Form/Type/Admin/SearchProductType.php @@ -30,6 +30,9 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormError; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; use Symfony\Component\Validator\Constraints as Assert; class SearchProductType extends AbstractType @@ -265,6 +268,28 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'label' => 'admin.list.sort.type', 'required' => false, ]) + ->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { + $form = $event->getForm(); + $create_datetime_start = $form['create_datetime_start']->getData(); + $create_datetime_end = $form['create_datetime_end']->getData(); + + $update_datetime_start = $form['update_datetime_start']->getData(); + $update_datetime_end = $form['update_datetime_end']->getData(); + + if (!empty($create_datetime_start) && !empty($create_datetime_end)) { + if ($create_datetime_start > $create_datetime_end) { + $form['create_datetime_start']->addError(new FormError(trans('admin.product.date_range_error'))); + $form['create_datetime_end']->addError(new FormError('')); + } + } + + if (!empty($update_datetime_start) && !empty($update_datetime_end)) { + if ($update_datetime_start > $update_datetime_end) { + $form['update_datetime_start']->addError(new FormError(trans('admin.product.date_range_error'))); + $form['update_datetime_end']->addError(new FormError('')); + } + } + }) ; } diff --git a/src/Eccube/Resource/locale/messages.en.yaml b/src/Eccube/Resource/locale/messages.en.yaml index 04bd8f9f6bc..71fbf4880b5 100644 --- a/src/Eccube/Resource/locale/messages.en.yaml +++ b/src/Eccube/Resource/locale/messages.en.yaml @@ -658,6 +658,7 @@ admin.product.delete_flag: Product Deletion Flag admin.product.search_category: Category Search admin.product.save_tag: Tags admin.product.create_date__card_title: Update +admin.product.date_range_error: End date is set after start date admin.product.move_to_category: Add / Edit a Category admin.product.move_to_tag: Add / Edit a Tag admin.product.move_to_product_class: Edit an Option diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index a23e7df9a75..90231eef57b 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -658,6 +658,7 @@ admin.product.delete_flag: 商品削除フラグ admin.product.search_category: カテゴリ検索 admin.product.save_tag: タグ登録 admin.product.create_date__card_title: 登録日・更新日 +admin.product.date_range_error: 終了日時は、開始日時より大きく設定してください admin.product.move_to_category: カテゴリの追加・編集 admin.product.move_to_tag: タグの追加・編集 admin.product.move_to_product_class: 商品規格の編集