バージョン選択

フォーラム

メニュー

オンライン状況

31 人のユーザが現在オンラインです。 (25 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 31
もっと...

サイト内検索

プラグイン > 開発について > 拡張した ShippingType でエンティティを取得したい

開発について

新規スレッドを追加する

フラット表示 前のトピック | 次のトピック
投稿者 スレッド
h_tanaka
投稿日時: 2018/5/24 17:47
対応状況: −−−
登録日: 2016/7/22
居住地: 愛媛県
投稿: 1650
Re: 拡張した ShippingType でエンティティを取得したい
umebius 様
ありがとうございます。

お届け先のFormを拡張して国情報と電話番号情報を追加したいと思っています。
なので、SUBMITのタイミングではないんです。。

イベントリスナー考慮前のソースを記載いたします。

class AdminShippingTypeExtension extends AbstractTypeExtension
{
    public $app;

    public function __construct(\Silex\Application $app)
    {
        $this->app = $app;
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $app = $this->app;
        $Shipping = $options['data'];    // ★ 取得できない

        $country_id = 392; // 日本
        $telCustom = null;
        if (!is_null($Shipping)) {
            $Country = $Shipping->getCountry();
            if ($Country) {
                $country_id = $Country->getId();
            }

            $plgShipping = $app['eccube.plugin.custom.repository.shipping']->findOneBy(array('Shipping' => $Shipping));
            if (!is_null($plgShipping)) {
                $telCustom = $plgShipping->getTelCustom();
            }
        }

        $builder
            ->add('country', 'eccube_country', array(
                'required' => false,
                'data' => $app['orm.em']->getReference("Eccube\Entity\Master\Country", $country_id),
            ))
            ->add('zip', 'zip', array(
                'required' => false,
            ))
            ->add('tel', 'tel', array(
                'required' => false,
            ))
            ->add(
                $builder->create('tel_custom', 'text', array(
                        'label' => '電話番号',
                        'required' => true,
                        'mapped' => false,
                        'constraints' => array(
                            new Assert\Regex(array(
                                'pattern' => "/^[\+\d-() ]+$/u",
                            )),
                        ),
                        'data' => $telCustom,
                    ))
                    ->addEventSubscriber(new \Eccube\EventListener\ConvertKanaListener())
            );
    }

    public function getExtendedType()
    {
        return 'shipping';
    }
}


----------------
EC-CUBE 《プラチナ》ランクパートナー
トエビス株式会社 田中 宏典
EC-CUBEの機能やデザインのカスタマイズ承ります。

フラット表示 前のトピック | 次のトピック


題名 投稿者 日時
   拡張した ShippingType でエンティティを取得したい h_tanaka 2018/5/22 9:35
     Re: 拡張した ShippingType でエンティティを取得したい minori 2018/5/23 14:32
       Re: 拡張した ShippingType でエンティティを取得したい h_tanaka 2018/5/24 16:04
         Re: 拡張した ShippingType でエンティティを取得したい umebius 2018/5/24 17:12
         Re: 拡張した ShippingType でエンティティを取得したい umebius 2018/5/24 17:21
         » Re: 拡張した ShippingType でエンティティを取得したい h_tanaka 2018/5/24 17:47
             Re: 拡張した ShippingType でエンティティを取得したい umebius 2018/5/25 7:58
               Re: 拡張した ShippingType でエンティティを取得したい h_tanaka 2018/5/25 12:08
                 Re: 拡張した ShippingType でエンティティを取得したい minori 2018/5/28 18:33
                   Re: 拡張した ShippingType でエンティティを取得したい h_tanaka 2018/5/29 11:34
                     Re: 拡張した ShippingType でエンティティを取得したい h_tanaka 2018/5/29 11:42

 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は89,159名です
総投稿数は110,046件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2314
5
umebius
2085
6
yuh
1819
7
h_tanaka
1650
8
red
1570
9
mcontact
1299
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.