バージョン選択

フォーラム

メニュー

オンライン状況

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

サイト内検索

プラグイン > 開発について > Form Extension で追加したフォームが認識されない

開発について

新規スレッドを追加する

スレッド表示 | 古いものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
h_tanaka
投稿日時: 2020/10/21 9:22
対応状況: −−−
登録日: 2016/7/22
居住地: 愛媛県
投稿: 1610
Form Extension で追加したフォームが認識されない
EC-CUBE 3.0.10

Form Extension で追加したフォームが認識されません。

受注登録ページにフォームを追加するために、 OrderDetailType を拡張した OrderDetailExtention を作成しました。
EC-CUBE 3.0.18 では正常に動作したのですが、EC-CUBE 3.0.10 でエラーになってしまいます。
原因わかりますでしょうか?

Twig_Error_Runtime in Template.php line 584:
Method "Test" for object "Symfony\Component\Form\FormView" does not exist in "/Test/Resource/template/admin/order_detail_prototype.twig" at line 2

OrderDetailExtention.php
<?php
namespace Plugin\Test\Form\Extension;

use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;

class OrderDetailExtention extends AbstractTypeExtension
{
    public $app;

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

    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('Test', 'hidden', array(
                'required' => false,
                'mapped' => false,
            ));
    }

    /**
     * {@inheritdoc}
     */
    public function getExtendedType()
    {
        return 'order_detail';
    }
}


Event.php
public function onRenderOrderEdit(TemplateEvent $event)
{
    if (!$this->app->isGranted('ROLE_ADMIN')) {
        return;
    }

    $source = $event->getSource();

    $search = '{{ include(\'Order/order_detail_prototype.twig\', { \'orderDetailForm\': form.OrderDetails.vars.prototype }) }}';
    $replace = $search.'{{ include(\'/Test/Resource/template/admin/order_detail_prototype.twig\', { \'orderDetailForm\': form.OrderDetails.vars.prototype }) }}';
    $source = str_replace($search, $replace, $source);

    $event->setSource($source);
}


order_detail_prototype.twig
{{ form_widget(orderDetailForm.Test, {'type': 'hidden'}) }}
スレッド表示 | 古いものから 前のトピック | 次のトピック | トップ


 



ログイン


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

統計情報

総メンバー数は88,286名です
総投稿数は109,688件です

投稿数ランキング

1
seasoft
7365
2
468
3217
3
AMUAMU
2712
4
nanasess
2303
5
umebius
2085
6
yuh
1818
7
h_tanaka
1610
8
red
1567
9
mcontact
1240
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
796
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.