diff --git a/README.md b/README.md index 745ae9c..fa2043c 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ The ideia is to facilitate the front development. You do not need to worry about ## ChangeLog +* 1.0.25 +1. Added \Zend\Form\Element\DateSelect support + * 1.0.24 1. Added setBasePath to specify an url for the files (see each section bellow) diff --git a/src/LosUi/Form/View/Helper/FormRow.php b/src/LosUi/Form/View/Helper/FormRow.php index 0d7c69e..471e82e 100644 --- a/src/LosUi/Form/View/Helper/FormRow.php +++ b/src/LosUi/Form/View/Helper/FormRow.php @@ -21,6 +21,7 @@ use Zend\Form\Element\Button; use Zend\Form\Element\MonthSelect; use Zend\Form\LabelAwareInterface; +use Zend\Form\Element\DateSelect; /** * Form row styled for Bootstrap 3. @@ -112,7 +113,25 @@ public function render(ElementInterface $element, $isHorizontal = false, $labelC $type = $element->getAttribute('type'); - if ($type != 'checkbox' && $type != 'submit' && $type != 'button' && $type != 'radio' && $type != 'file' && $type != 'multi_checkbox') { + if ($element instanceof DateSelect) { + $attrs = $element->getDayAttributes(); + $classAttributes = (in_array('class', $attrs) ? $attrs['class'].' ' : ''); + $classAttributes = $classAttributes.'form-control'; + $attrs['class'] = $classAttributes; + $element->setDayAttributes($attrs); + + $attrs = $element->getMonthAttributes(); + $classAttributes = (in_array('class', $attrs) ? $attrs['class'].' ' : ''); + $classAttributes = $classAttributes.'form-control'; + $attrs['class'] = $classAttributes; + $element->setMonthAttributes($attrs); + + $attrs = $element->getYearAttributes(); + $classAttributes = (in_array('class', $attrs) ? $attrs['class'].' ' : ''); + $classAttributes = $classAttributes.'form-control'; + $attrs['class'] = $classAttributes; + $element->setYearAttributes($attrs); + } elseif ($type != 'checkbox' && $type != 'submit' && $type != 'button' && $type != 'radio' && $type != 'file' && $type != 'multi_checkbox') { $classAttributes = ($element->hasAttribute('class') ? $element->getAttribute('class').' ' : ''); $classAttributes = $classAttributes.'form-control'; $element->setAttribute('class', $classAttributes); @@ -204,7 +223,7 @@ public function render(ElementInterface $element, $isHorizontal = false, $labelC // Multicheckbox elements have to be handled differently as the HTML standard does not allow nested // labels. The semantic way is to group them inside a fieldset - if (!$isHorizontal && ($type === 'multi_checkbox' || $type === 'radio' || $element instanceof MonthSelect)) { + if (!$isHorizontal && ($type === 'multi_checkbox' || $type === 'radio' || ($element instanceof MonthSelect && !$element instanceof DateSelect))) { $markup = sprintf('
%s%s
', $label, $elementString); } elseif ($type == 'checkbox') { // Checkboxes need special treatment too @@ -234,6 +253,8 @@ public function render(ElementInterface $element, $isHorizontal = false, $labelC if ($element instanceof Button) { $labelOpen = $labelClose = $label = ''; $addDivClass = ' col-xs-offset-'.$labelColumns; + } elseif ($element instanceof DateSelect) { + $elementString = '
'.$elementString.'
'; } if ($type == 'radio') { $addDivClass = ' radio';