Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save webbingstudio/43d4f35102a662da5e8a18790c82e1d8 to your computer and use it in GitHub Desktop.
Save webbingstudio/43d4f35102a662da5e8a18790c82e1d8 to your computer and use it in GitHub Desktop.
a-blog cmsのカスタムユニット:セレクトボックス
<style>
.acms-admin-ex-notice {
margin: 5px 0;
padding: 5px;
background-color: #F9F9F9;
color: #339900;
font-size: .75rem;
line-height: 1.25;
}
</style>
<!-- BEGIN custom_hoge -->
<table class="entryFormColumnSettingTable entryFormColumnTable">
<tr>
<td class="entryFormFileControl">
<table class="entryFormColumnSettingTable">
<!-- ユニットの入力項目:セレクトボックスの場合 -->
<tr>
<th style="white-space: nowrap;">セレクトボックス</th>
<td>
<select name="hoge_select{id}" class="acms-admin-form-width-full">
<option value="">(選択してください)</option>
<option value="選択肢1"{hoge_select:selected#選択肢1}>選択肢1</option>
<option value="選択肢2"{hoge_select:selected#選択肢2}>選択肢2</option>
<option value="選択肢3"{hoge_select:selected#選択肢3}>選択肢3</option>
</select>
<input type="hidden" name="unit{id}[]" value="hoge_select{id}" />
<p class="acms-admin-ex-notice">入力項目の説明文です入力項目の説明文です入力項目の説明文です入力項目の説明文です入力項目の説明文です入力項目の説明文です</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END custom_hoge -->
<!-- BEGIN unit#custom_hoge -->
<table class="acms-table acms-table-borderd">
<!-- ユニットの表示:セレクトボックスの場合 -->
<tr>
<th>セレクトボックス</th>
<td>
<!-- BEGIN_IF [{hoge_select}/em] -->
選択肢null
<!-- ELSE -->
<strong>{hoge_select}</strong>
<!-- END_IF -->
</td>
</tr>
</table>
<!-- END unit#custom_hoge -->
@webbingstudio
Copy link
Author

ファイルユニットに使用されているtd.entryFormFileControlを改変。モバイルに対応する。
td.entryFormFileControlは、th要素の幅が8emと狭いので、th要素にnowrapを明示している。
p.acms-admin-ex-notice は注釈を表示するための追加クラス。2.6の時点ではacms.cssにちょうど良いコンポーネントがないので…

カスタムユニットではフォームオプションを利用できない。つまり必須チェックや入力した値の自動校正ができない(らしい)。
なのでnullではまずい場合は、ラジオボタンと同様、nullを初期値扱いとしたほうが良いかもしれない。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment