開発メモ

開発用のメモです。

EC CUBE 日付項目の共通化

selected を .value 有り無し統一できりゃこれだけでいけるが・・

date_time.tpl

<div class="attention">
    <!--{$arrErr[$year]}-->
    <!--{$arrErr[$year2]}-->
</div>
<!--{if $arrErr[$year]|cat:$arrErr[$year2] != ""}-->
<div <!--{sfSetErrorStyle}-->>
    <!--{else}-->
    <div>
        <!--{/if}-->
        <select name="<!--{$year}-->"  >
            <option value="" selected="selected">------</option>
            <!--{html_options options=$arrYear selected=$arrForm[$year]}-->
        </select><select name="<!--{$month}-->" >
            <option value="" selected="selected">----</option>
            <!--{html_options options=$arrMonth selected=$arrForm[$month]}-->
        </select><select name="<!--{$day}-->" >
            <option value="" selected="selected">----</option>
            <!--{html_options options=$arrDay selected=$arrForm[$day]}-->
        </select>
        日~
        <select name="<!--{$year2}-->"  >
            <option value="" selected="selected">------</option>
            <!--{html_options options=$arrYear2 selected=$arrForm[$year2]}-->
        </select><select name="<!--{$month2}-->" >
            <option value="" selected="selected">----</option>
            <!--{html_options options=$arrMonth2 selected=$arrForm[$month2]}-->
        </select><select name="<!--{$day2}-->" >
            <option value="" selected="selected">----</option>
            <!--{html_options options=$arrDay2 selected=$arrForm[$day2]}-->
        </select><!--{if $arrErr[$year]|cat:$arrErr[$year2] != ""}-->
    </div>
    <!--{else}-->
</div>
<!--{/if}-->

search_date_time.tpl

<div class="attention">
    <!--{$arrErr[$year]}-->
    <!--{$arrErr[$year2]}-->
</div>
<!--{if $arrErr[$year]|cat:$arrErr[$year2] != ""}-->
<div <!--{sfSetErrorStyle}-->>
    <!--{else}-->
    <div>
        <!--{/if}-->
        <select name="<!--{$year}-->"  >
            <option value="" selected="selected">------</option>
            <!--{html_options options=$arrYear selected=$arrForm[$year]}-->
        </select><select name="<!--{$month}-->" >
            <option value="" selected="selected">----</option>
            <!--{html_options options=$arrMonth selected=$arrForm[$month]}-->
        </select><select name="<!--{$day}-->" >
            <option value="" selected="selected">----</option>
            <!--{html_options options=$arrDay selected=$arrForm[$day]}-->
        </select>
        日~
        <select name="<!--{$year2}-->"  >
            <option value="" selected="selected">------</option>
            <!--{html_options options=$arrYear2 selected=$arrForm[$year2]}-->
        </select><select name="<!--{$month2}-->" >
            <option value="" selected="selected">----</option>
            <!--{html_options options=$arrMonth2 selected=$arrForm[$month2]}-->
        </select><select name="<!--{$day2}-->" >
            <option value="" selected="selected">----</option>
            <!--{html_options options=$arrDay2 selected=$arrForm[$day2]}-->
        </select><!--{if $arrErr[$year]|cat:$arrErr[$year2] != ""}-->
    </div>
    <!--{else}-->
</div>
<!--{/if}-->

サンプル

<tr>
    <th>登録・更新日</th>
    <td colspan="3">
        <!--{include file="`$smarty.const.TEMPLATE_ADMIN_REALDIR`adminparts/search_date_time_value.tpl"
                year="search_startyear"
                month="search_startmonth"
                day="search_startday"

                year2="search_endyear"
                month2="search_endmonth"
                day2="search_endday"
                
                arrYear=$arrStartYear
                arrMonth=$arrStartMonth
                arrDay=$arrStartDay
                
           arrYear2=$arrEndYear
           arrMonth2=$arrEndMonth
           arrDay2=$arrEndDay
       }-->
    </td>
</tr>
Twitter: @asahina_alice