LoginSignup
2
0

More than 5 years have passed since last update.

【EC-CUBE】同一画面で複数の住所フォームを持つ場合の対応

Posted at

同一画面で複数の住所フォームを持つ場合の対応
EC-CUBEではYubinBangoのライブラリを使用しています。
詳しい使い方は公式リポジトリを参照してください。

概要

そのままコピペで住所フォームを増やすだけだと1個の郵便番号の変更で全てのフォームがクリアされてしまう。

対応方法

  1. 住所フォームごとに h-adr クラスで囲む
  2. h-adr ごとに <span class="p-country-name" style="display:none;">Japan</span> を記載する

修正前

例えば1画面に単一の住所フォームの場合は以下のようになっている。

<form action="{{ url('hogehoge') }}" class="h-adr">
    <span class="p-country-name" style="display:none;">Japan</span>

    {# ... #}

    {# 住所フォーム #}{{ form_widget(form.postal_code) }}
    {{ form_widget(form.address) }}

    {# ... #}

</form>

修正後

例えば以下のようにすればお互いのフォームが干渉しない。

<form action="{{ url('hogehoge') }}">

    {# ... #}

    {% for form in forms %}
        <div class="h-adr">
            <span class="p-country-name" style="display:none;">Japan</span>

            {# ... #}

            {# 住所フォーム #}{{ form_widget(form.postal_code) }}
            {{ form_widget(form.address) }}

            {# ... #}

        </div>
    {% endfor %}

    {# ... #}

</form>

参考

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