Note that there are some explanatory texts on larger screens.

plurals
  1. POzend decorator forms create table of rows within table
    primarykey
    data
    text
    <p>I have the following code and i would like to create the form in a table of rows. The 1st for loop is one table and the the 2nd for loop will be sub tables. These subtables I will use javascript to show and hide them using a plus/minus button.</p> <pre><code> &lt;?php class Application_Form_LineData extends Zend_Form { private $lineId; private $dataId; private $name; public function init() { /* Form Elements &amp; Other Definitions Here ... */ } public $elementDecoration = array( 'ViewHelper', array(array('data' =&gt; 'HtmlTag'), array('tag' =&gt; 'td')) ); public $elementRowDecoration = array( 'ViewHelper', array(array('row' =&gt; 'HtmlTag'), array('tag' =&gt; 'tr')) ); public $elementTableDecoration = array( 'ViewHelper', array(array('data' =&gt; 'HtmlTag'), array('tag' =&gt; 'td')), array(array('row' =&gt; 'HtmlTag'), array('tag' =&gt; 'tr')) ); public function setLineId($lineId) { $this-&gt;lineId = $lineId; } public function setName($name) { $this-&gt;name = $name; } public function setDataId($dataId) { $this-&gt;dataId = $dataId; } public function startform($entries) { $this-&gt;setMethod('post') -&gt;setAttrib('enctype', 'multipart/form-data'); //$this-&gt;setName('linedata'); //$this-&gt;setAction($_SERVER["REQUEST_URI"]); //$this-&gt;setAction('line/submit'); $count = count($entries); for($i=0;$i&lt;$count;$i++){ $this-&gt;addElement('text', 'lineid_'.$entries[$i]['PGA_Id'], array( 'required' =&gt; true, 'value' =&gt; $entries[$i]['PGA_Id'], 'decorators' =&gt; $this-&gt;elementDecoration, )); $this-&gt;addElement('text', 'name_'.$entries[$i]['PGA_Name'], array( 'required' =&gt; true, 'value' =&gt; $entries[$i]['PGA_Name'], 'readonly' =&gt;true, 'decorators' =&gt; $this-&gt;elementDecoration )); $this-&gt;addElement('checkbox', 'check'.$entries[$i]['PGA_Id'], array( 'decorators' =&gt; $this-&gt;elementDecoration, )); $this-&gt;setElementDecorators( array( 'ViewHelper', 'Label' ), array( 'lineid_'.$entries[$i]['PGA_Id'], 'name_'.$entries[$i]['PGA_Name'], 'check'.$entries[$i]['PGA_Id'] ) ); // Data sets for each line /* $countData = count($entries[$i]['Data_Set']); for($x=0;$x&lt;$countData;$x++){ $this-&gt;addElement('hidden', 'dataid_'.$entries[$i]['Data_Set'][$x]['PGA_Id'], array( 'required' =&gt; true, 'decorators' =&gt; $this-&gt;elementDecoration, 'decorators' =&gt; $this-&gt;elementRowDecoration, //'decorators' =&gt; $this-&gt;elementTableDecoration, )); $this-&gt;addElement('text', 'name_'.$entries[$i]['Data_Set'][$x]['PGA_Name'], array( 'required' =&gt; true, 'value' =&gt; $entries[$i]['Data_Set'][$x]['PGA_Name'], 'readonly' =&gt;true, 'decorators' =&gt; $this-&gt;elementDecoration )); $this-&gt;addElement('hidden', 'path_'.$entries[$i]['Data_Set'][$x]['PGA_Path'], array( 'required' =&gt; true, 'value' =&gt; $entries[$i]['Data_Set'][$x]['PGA_Path'], 'readonly' =&gt;true, 'decorators' =&gt; $this-&gt;elementDecoration )); $this-&gt;addElement('checkbox', 'check'.$entries[$i]['Data_Set'][$x]['PGA_Id'], array( 'decorators' =&gt; $this-&gt;elementDecoration )); } */ } //show var here //var_dump($this-&gt;lineId); $this-&gt;addElement('submit', 'submit', array( 'ignore' =&gt; true, 'label' =&gt; 'Submit', 'decorators' =&gt; $this-&gt;elementDecoration )); /* $this-&gt;setElementDecorators(array( 'ViewHelper', 'Errors', array(array('data' =&gt; 'HtmlTag'), array('tag' =&gt; 'td')), //array(array('row' =&gt; 'HtmlTag'), array('tag' =&gt; 'tr')) )); */ $this-&gt;setDecorators(array( 'FormElements', array(array('data'=&gt;'HtmlTag'),array('tag'=&gt;'table')), 'Form' )); //print_r($this); //exit(); return $this; } //$this-&gt;setDecorators(array('FormElements', array('SimpleTable', ), 'Form')); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload