From 1bc2bae1847c0e8a6c977019b8add1231d2c6fa6 Mon Sep 17 00:00:00 2001 From: Alejandro Fiore Date: Fri, 12 Jun 2015 09:43:32 -0300 Subject: [PATCH] Fix bug using twb-row-open and column-size options Fix bug when using twb-row-open, twb-row-close and column-size inside a form, not a collection. Before, was always rendered all form elements inside a
. Now open the
in the element with twb-row-open, and close it in the twb-row-close element. --- src/TwbBundle/Form/View/Helper/TwbBundleForm.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleForm.php b/src/TwbBundle/Form/View/Helper/TwbBundleForm.php index 17c27a0..05ac0c4 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleForm.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleForm.php @@ -61,9 +61,14 @@ public function render(FormInterface $oForm, $sFormLayout = self::LAYOUT_HORIZON $bHasColumnSizes = false; $sFormContent = ''; $oRenderer = $this->getView(); + $rowsOpened = 0; foreach ($oForm as $oElement) { $aOptions = $oElement->getOptions(); - if (!$bHasColumnSizes && !empty($aOptions['column-size'])) { + if (isset($aOptions['twb-row-open']) && $aOptions['twb-row-open']) { + $sFormContent .= '
'; + $rowsOpened++; + } + if (!$bHasColumnSizes && !empty($aOptions['column-size']) && $rowsOpened === 0) { $bHasColumnSizes = true; } //Define layout option to form elements if not already defined @@ -72,6 +77,10 @@ public function render(FormInterface $oForm, $sFormLayout = self::LAYOUT_HORIZON $oElement->setOptions($aOptions); } $sFormContent .= $oElement instanceof FieldsetInterface ? $oRenderer->formCollection($oElement) : $oRenderer->formRow($oElement); + if (isset($aOptions['twb-row-close']) && $aOptions['twb-row-close']) { + $sFormContent .= '
'; + $rowsOpened--; + } } if ($bHasColumnSizes && $sFormLayout !== self::LAYOUT_HORIZONTAL) { $sFormContent = sprintf(self::$formRowFormat, $sFormContent);