From d91b65261f1c90901d432e804ac55d879e0809cb Mon Sep 17 00:00:00 2001 From: Peter Lohse Date: Fri, 18 Dec 2020 19:17:12 +0100 Subject: [PATCH] Add CheckboxFormField (#3812) * added implementation of a checkbox form field for boolen values * fixed indentation * added __checkboxFormField to syncTemplates.json * added missing comma --- .../templates/__checkboxFormField.tpl | 14 ++++++++ syncTemplates.json | 1 + .../acp/templates/__checkboxFormField.tpl | 14 ++++++++ .../builder/field/CheckboxFormField.class.php | 32 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 com.woltlab.wcf/templates/__checkboxFormField.tpl create mode 100644 wcfsetup/install/files/acp/templates/__checkboxFormField.tpl create mode 100644 wcfsetup/install/files/lib/system/form/builder/field/CheckboxFormField.class.php diff --git a/com.woltlab.wcf/templates/__checkboxFormField.tpl b/com.woltlab.wcf/templates/__checkboxFormField.tpl new file mode 100644 index 0000000000..af2e22d073 --- /dev/null +++ b/com.woltlab.wcf/templates/__checkboxFormField.tpl @@ -0,0 +1,14 @@ +
getClasses()|empty} class="{implode from=$field->getClasses() item='class' glue=' '}{$class}{/implode}"{/if}{foreach from=$field->getAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{if !$field->checkDependencies()} style="display: none;"{/if}> +
+
+ + + {include file='__formFieldDescription'} + {include file='__formFieldErrors'} + {include file='__formFieldDependencies'} + {include file='__formFieldDataHandler'} +
+
diff --git a/syncTemplates.json b/syncTemplates.json index e0f92d2618..c490d47c3f 100644 --- a/syncTemplates.json +++ b/syncTemplates.json @@ -6,6 +6,7 @@ "templates": [ "__aclFormField", "__booleanFormField", + "__checkboxFormField", "__contentLanguageFormField", "__dateFormField", "__emailFormField", diff --git a/wcfsetup/install/files/acp/templates/__checkboxFormField.tpl b/wcfsetup/install/files/acp/templates/__checkboxFormField.tpl new file mode 100644 index 0000000000..af2e22d073 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/__checkboxFormField.tpl @@ -0,0 +1,14 @@ +
getClasses()|empty} class="{implode from=$field->getClasses() item='class' glue=' '}{$class}{/implode}"{/if}{foreach from=$field->getAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{if !$field->checkDependencies()} style="display: none;"{/if}> +
+
+ + + {include file='__formFieldDescription'} + {include file='__formFieldErrors'} + {include file='__formFieldDependencies'} + {include file='__formFieldDataHandler'} +
+
diff --git a/wcfsetup/install/files/lib/system/form/builder/field/CheckboxFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/CheckboxFormField.class.php new file mode 100644 index 0000000000..7df2a5b09e --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/field/CheckboxFormField.class.php @@ -0,0 +1,32 @@ + + * @package WoltLabSuite\Core\System\Form\Builder\Field + * @since 5.3 + */ +class CheckboxFormField extends BooleanFormField { + /** + * @inheritDoc + */ + protected $templateName = '__checkboxFormField'; + + /** + * @inheritDoc + */ + public function getHtml() { + return WCF::getTPL()->fetch( + $this->templateName, + 'wcf', + [ + 'field' => $this, + ] + ); + } +} -- 2.20.1