0

according to this post: Zend Framework 2 - Form Element Decorators , i've tried the solution from iroybot (thanks to him) and it worked. but new problem occurs. Here the details:

In the render method in FormCollection.php (View Helper) i throw object like this:

<?php
 namespace Cust\View\Helper;

use Zend\Form\ElementInterface;
use Zend\Form\View\Helper\FormCollection as BaseFormCollection;

class  FormCollection extends BaseFormCollection
{
public function render(ElementInterface $element)
{


    return sprintf('<table  class="table table-condensed">%s</table>',parent::render($element));
}
}

and in the render method in FormElement.php (View Helper), i throw :

<?php
 namespace Cust\View\Helper;

 use Zend\Form\ElementInterface;
 use Zend\Form\View\Helper\FormElement as BaseFormElement;

 class FormElement extends BaseFormElement
{
public function render(ElementInterface $element)
{
    $req = '';
    if($element->getOption('required')){
        $req = 'required';
    }


    return sprintf('<tr><td>%s</td><td>%s</td>  </tr>',$element->getLabel(),parent::render($element));

}
}

and the form render in the table perfectly. but before table, the label show in the tag label. so the label display twice, first in span tag, and the second in the row of the table...

i don't know how to solve this..

please give me advice.. thanks

bestregards

Community
  • 1
  • 1
e-Beng
  • 11
  • 3
  • We would need to see your code. Your custom `ViewHelpers`, as well as the code that you use to output your Form. On a SideNote: the HTML that you are creating is semantically useless and i strongly urge you to not use Tables to layout your Form. There's far better solutions. A Table like yours would be useless to anyone relying on software to read your webpage. – Sam Aug 24 '13 at 07:54
  • thanks Sam, I have edit the question with display the view helper.. – e-Beng Aug 25 '13 at 09:13
  • thanks Sam, I have edit the question with display the view helper.. – e-Beng Aug 25 '13 at 09:13
  • thanks Sam, I have edit the question with display the view helper.. – e-Beng Aug 25 '13 at 09:13

0 Answers0