-
Notifications
You must be signed in to change notification settings - Fork 140
fix #4303 【メール】マルチチェックボックスの各選択肢が自動でspanタグで囲まれる問題を解決 #4316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 5.2.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+183
to
+203
|
||
| // inputタグに出力されないようにunset | ||
| unset($attributes['templateVars.tag']); | ||
| } | ||
|
Comment on lines
+179
to
+206
|
||
| $out = $this->select($fieldName, $options, $attributes); | ||
| break; | ||
| case 'file': | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ヘルプテキストの例に誤解を招く可能性があります。「div class="checkbox"」という例は、クラス属性を含むタグを指定できることを示唆していますが、実際のコード実装ではこれが適切に処理されていません(セキュリティとロジックの問題については他のコメントを参照)。
実装が修正されるまで、ヘルプテキストの例を単純なタグ名のみに変更することを推奨します。例:「templateVars.tag|div」