Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Fix bug using twb-row-open and column-size options inside a form without fieldset #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/TwbBundle/Form/View/Helper/TwbBundleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= '<div class="row">';
$rowsOpened++;
}
if (!$bHasColumnSizes && !empty($aOptions['column-size']) && $rowsOpened === 0) {
$bHasColumnSizes = true;
}
//Define layout option to form elements if not already defined
Expand All @@ -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 .= '</div>';
$rowsOpened--;
}
}
if ($bHasColumnSizes && $sFormLayout !== self::LAYOUT_HORIZONTAL) {
$sFormContent = sprintf(self::$formRowFormat, $sFormContent);
Expand Down