For Those who are stuck like me i customized the helper FormCollection (don't know if there's a better way to do X/)
put this class under
< module name> /src/ < module name >/View/Helper/FormCollection.php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @CustomizedBy Fabio Tagliabue
* @UpdaterWS http://www.polarfoxlab.com
*/
namespace Users\View\Helper;
use Zend\Form\ElementInterface;
use Zend\Form\View\Helper\FormCollection as BaseFormCollection;
class FormCollection extends BaseFormCollection {
public function __invoke(ElementInterface $element = null, $wrap = true,$ExternalWrapper = '',$RowWrapper = 'div')
{
if (!$element) {
return $this;
}
$this->setShouldWrap($wrap);
return $this->render($element,$ExternalWrapper,$RowWrapper);
}
public function render(ElementInterface $element,$ExternalWrapper,$RowWrapper)
{
$renderer = $this->getView();
if (!method_exists($renderer, 'plugin')) {
// Bail early if renderer is not pluggable
return '';
}
$markup = '';
$templateMarkup = '';
$escapeHtmlHelper = $this->getEscapeHtmlHelper();
$elementHelper = $this->getElementHelper();
$fieldsetHelper = $this->getFieldsetHelper();
if ($element instanceof CollectionElement && $element->shouldCreateTemplate()) {
$templateMarkup = $this->renderTemplate($element);
}
$markup .= $this->PrintWrapper($ExternalWrapper,true);
foreach ($element->getIterator() as $elementOrFieldset) {
$markup .= $this->PrintWrapper($RowWrapper,true);
if ($elementOrFieldset instanceof FieldsetInterface) {
$markup .= $fieldsetHelper($elementOrFieldset);
} elseif ($elementOrFieldset instanceof ElementInterface) {
$markup .= $elementHelper($elementOrFieldset);
}
$markup .= $this->PrintWrapper($RowWrapper,false);
}
$markup .= $this->PrintWrapper($ExternalWrapper,false);
// If $templateMarkup is not empty, use it for simplify adding new element in JavaScript
if (!empty($templateMarkup)) {
$markup .= $templateMarkup;
}
// Every collection is wrapped by a fieldset if needed
if ($this->shouldWrap) {
$label = $element->getLabel();
if (!empty($label)) {
if (null !== ($translator = $this->getTranslator())) {
$label = $translator->translate(
$label, $this->getTranslatorTextDomain()
);
}
$label = $escapeHtmlHelper($label);
$markup = sprintf(
'<fieldset><legend>%s</legend>%s</fieldset>',
$label,
$markup
);
}
}
return $markup;
}
/*
* @param array wrapper keys are attribute + type is html tag
* @param bool open if need to open or close tag
*/
private function PrintWrapper($wrapper,$open=true)
{
$tag='';
if(!empty($wrapper))
{
if($open) $tag='<';
else $tag="</";
foreach($wrapper as $attribute => $value)
{
if(strtolower($attribute)=="type")
$tag.="{$value}";
else
$tag.=" {$attribute}='{$value}'";
}
$tag.='>';
}
return $tag;
}
}
then go to < module name > /Module.php
and add this
public function getViewHelperConfig() {
return array(
'invokables' => array(
'FormCollection' => '< module name >\View\Helper\FormCollection',
)
);
}
now for using it in the form page call
echo $this->formCollection($form,true,'',array('type'=>'div','class'=>'form-group'));
the third parameter is ExternalWrapper and the fourth one is the RowWrapper
just set the type for which tag you want to use and then the other property you want to assign :D
hope that this could help someone :D