diff --git a/plugins/bc-admin-third/templates/plugin/BcMail/Admin/element/MailFields/form.php b/plugins/bc-admin-third/templates/plugin/BcMail/Admin/element/MailFields/form.php index 1820243974..b4f7460f92 100644 --- a/plugins/bc-admin-third/templates/plugin/BcMail/Admin/element/MailFields/form.php +++ b/plugins/bc-admin-third/templates/plugin/BcMail/Admin/element/MailFields/form.php @@ -247,6 +247,18 @@ class="col-head bca-form-table__label">BcAdminForm->label('opt BcAdminForm->control('options', ['type' => 'text', 'size' => 40, 'maxlength' => 255]) ?> BcAdminForm->error('options') ?> + +
+

inputタグに対してオプションを設定します。

+
+
placeholder
+
プレースホルダー:利用するには、次の形式のように | 区切りで入力します。「placeholder|プレースホルダーの内容」
+
empty
+
セレクトボックスの何も選択していないときの表示は、次の形式のように | 区切りで入力します。「empty|何も選択していないときのメッセージ」
+
templateVars.tag
+
マルチチェックボックスでそれぞれのインプットタグをラッピングする要素を指定します。例)templateVars.tag|div class="checkbox"(div class="checkbox"で囲む)
※デフォルトはspanタグでラッピングされます。
+
+
diff --git a/plugins/bc-mail/src/View/Helper/MailformHelper.php b/plugins/bc-mail/src/View/Helper/MailformHelper.php index d6530ed63a..b0cf195594 100755 --- a/plugins/bc-mail/src/View/Helper/MailformHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailformHelper.php @@ -175,6 +175,35 @@ public function control(string $fieldName, array $attributes = []): string $attributes['value'] = null; $attributes['empty'] = false; $attributes['templateVars']['tag'] = 'span'; + // オプションでtemplateVars.tagが指定されていた場合の対応 + if (!empty($attributes['templateVars.tag'])) { + // 取得した値が有効なタグか確認 + $validTags = ['div', 'span', 'p', 'li', 'dt', 'dd', 'label']; + $rawTemplateTag = $attributes['templateVars.tag']; + foreach ($validTags as $validTag) { + // templateVars.tagが有効なタグ名から始まっている場合、$attributes['templateVars']['tag'] にセット + if (str_starts_with($rawTemplateTag, $validTag)) { + // 検証済みのタグ名のみをtemplateVars['tag']にセット + $attributes['templateVars']['tag'] = $validTag; + // 先頭のタグ名以降の文字列を取得(例: ' class="checkbox"') + $rest = trim(substr($rawTemplateTag, strlen($validTag))); + if ($rest !== '') { + $rests = explode(' ', $rest); + foreach ($rests as $key => $restPart) { + // タグ名を除外した属性値の中で、onclickやonchangeなどのイベント属性が含まれている場合、unsetする + if (str_starts_with($restPart, 'on')) { + unset($rests[$key]); + } + } + if (!empty($rests) && isset($attributes['templateVars']['tag'])) { + $attributes['templateVars']['tag'] .= ' ' . implode(' ', $rests); + } + } + } + } + // inputタグに出力されないようにunset + unset($attributes['templateVars.tag']); + } $out = $this->select($fieldName, $options, $attributes); break; case 'file':