Hi Vince, I wrote something similar to this for a project a few weeks ago, it wasn't perfect but it got the job done.
+-------+-------+-------+ | Label | Label | Label | +-------+-------+-------+ | Value | Value | Value | +-------+-------+-------+ | Value | Value | Value | +-------+-------+-------+ |New Row| +-------+ Was the general layout, I chucked it up on pastebin for someone else. Here's the element http://pastebin.com/m438d1001 and the decorator http://pastebin.com/d840e740 I think there may have been a few bugfixes to the element as well but the usage went something like this. $form->addElement(new Acer_Form_Element_Flex('teachers', array( 'elements' => array( $form->createElement('text', 'name', array('label' => 'Name', 'class' => 'inputbox', 'size' => 35)), $form->createElement('text', 'email', array('label' => 'Email', 'class' => 'inputbox', 'size' => 35, 'validators' => array('EmailAddress'))) ), 'validators' => array(new Acer_Validate_Teachers()) ) )); This results in a teachers table with two columns, one for name and one for email with an email address validator on the email column. Clicking on the new row adds a new teacher row the form. I don't think the code itself is ideal, it's a little messy in parts. But it was a blast to write, and loosely based off a tutorial by Matthew Weier O'Phinney Thanks, Daniel. On 5/05/09 7:52 AM, "Vince42" <[email protected]> wrote: > Hi, > > I need to render data tables in my form with the layout > > +-------+-------+-------+ > | Label | Label | Label | > +-------+-------+-------+ > | Value | Value | Value | > +-------+-------+-------+ > > I tested all kinds of methods like rendering with > > - composite decorator > - standard decorators > - view script decorator > - view script > > but none of the solutions looks really nice - they are all cluttered > with too many lines of code - and I simply fear that I will be unable to > refactor / build new functionalities in a few weeks of time, when the > focus of development is somewhere else. > > The best solution would be theoretically to generate all the form data > as XML and to build the whole form utilizing XSLT - but I neither want > to override all decorators and view facilities in order to produce the > whole site as XML, nor do I think that this is the way that ZF was > designed to work, thus I prefer to stick with what is there. > > I also tried to use definition lists and to display them in table layout > using CSS, but that solution is also suboptimal - and eventually the > table environment is there for exactly this purpose, isn't it? :P > > As the forms are parameter driven and the data is dynamically generated, > I also cannot specify forms for each purpose. And passing the parameters > to view scripts just shifts the problem from the form to the view script > code. > > Stop yawning. :) > > As I already spent two months on refactoring my whole form over and over > again, I really would like to hear your professional opinion on how to > implement a parameter and database driven form, which will render a > (theoretically) unlimited amount of form elements, where some of them > represent table data while sticking as much as possible to the design > ideas of ZF. > > Thx a lot in advance! ------------------------------------------------ Please consider the environment before you print
