[FEATURE] Add multiple parameter in f:form.checkbox 57/33257/5
authorStefan Froemken <froemken@gmail.com>
Fri, 10 Oct 2014 23:12:19 +0000 (01:12 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 24 Oct 2014 21:15:52 +0000 (23:15 +0200)
This patch introduce the multiple parameter
for f:form.checkbox ViewHelper of fluid.

Resolves: #61529
Releases: master,6.2
Change-Id: Ic02b9aaeb19f09be438c18212c5b2f5842bf7468
Reviewed-on: http://review.typo3.org/33257
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Ernesto Baschny <ernst@cron-it.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-61529-AddMultipleParameterToCheckboxViewHelper.rst [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-61529-AddMultipleParameterToCheckboxViewHelper.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-61529-AddMultipleParameterToCheckboxViewHelper.rst
new file mode 100644 (file)
index 0000000..bf8baf0
--- /dev/null
@@ -0,0 +1,25 @@
+===========================================================
+Feature: #61529 - Add multiple parameter to f:form.checkbox
+===========================================================
+
+Description
+===========
+
+Introduce parameter "multiple" for f:form.checkbox ViewHelper.
+
+::
+
+<f:form action="create" method="POST" name="pizza" object="{pizza}">
+       <f:form.checkbox property="covering" multiple="1" value="salami" /><br />
+       <f:form.checkbox property="covering" multiple="1" value="ham" /><br />
+       <f:form.checkbox property="covering" multiple="1" value="cheese" /><br />
+       <f:form.submit value="Send" />
+</f:form>
+
+..
+
+Impact
+======
+
+If you add the parameter "multiple" to your checkboxes, it automatically
+appends [] to the name of your checkbox.
\ No newline at end of file
index 6019aa0..dfccd7c 100644 (file)
@@ -65,11 +65,12 @@ class CheckboxViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
         * Renders the checkbox.
         *
         * @param boolean $checked Specifies that the input element should be preselected
+        * @param boolean $multiple Specifies whether this checkbox belongs to a multivalue (is part of a checkbox group)
         * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
         * @return string
         * @api
         */
-       public function render($checked = NULL) {
+       public function render($checked = NULL, $multiple = NULL) {
                $this->tag->addAttribute('type', 'checkbox');
 
                $nameAttribute = $this->getName();
@@ -89,11 +90,10 @@ class CheckboxViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
                                        $checked = in_array($valueAttribute, $propertyValue);
                                }
                                $nameAttribute .= '[]';
-                       } elseif (($multiple = FALSE) === TRUE) {
-                               // @todo: implement correct as in Flow.Fluid
+                       } elseif ($multiple === TRUE) {
                                $nameAttribute .= '[]';
                        } elseif ($checked === NULL && $propertyValue !== NULL) {
-                               $checked = (boolean) $propertyValue === (boolean) $valueAttribute;
+                               $checked = (bool)$propertyValue === (bool)$valueAttribute;
                        }
                }
                $this->registerFieldNameForFormTokenGeneration($nameAttribute);
@@ -106,4 +106,4 @@ class CheckboxViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
                $hiddenField = $this->renderHiddenFieldForEmptyValue();
                return $hiddenField . $this->tag->render();
        }
-}
+}
\ No newline at end of file