Re: Creating multiple elements of the same fields into an array with FormBuilder

From: Date: Thu, 27 Oct 2005 13:05:45 +0000
Subject: Re: Creating multiple elements of the same fields into an array with FormBuilder
References: 1 2 3 4 5 6 7 8  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21675@lists.php.net to get a copy of this message
However dodgy it is this gave me the same result, however validation doesnt get applied to it. Im displaying this from an ajax method, which gets displayed in the form just above the dynamic rendered form $this->form = new HTML_QuickForm('frmTest'); $artist_list = $artists->getArtists(); $this->form->addElement('select', 'row_limit', '',array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20),array("id"=
"row_limit"),$displayLimit);
$this->form-
addElement('button','update_rows_btn','Show',array('onclick'=>"updateList(document.getElementById('row_limit').options[document.getElementById('row_limit').selectedIndex].text);"));
for ($i=0; $i < $displayLimit; $i++) { $this->form->addElement('text', 'track_titles['.$i.'][track_title]', 'Track Title:',array('size'=>40)); $this->form->addElement('select', 'track_titles['.$i.'][artistID]', 'Artist:',$artist_list); $this->form->addElement('date', 'track_titles['.$i.'][duration]', 'Duration:', array('format'=>'His')); $this->form->addElement('text', 'track_titles['.$i.'][track_position]', 'Track Position:',array('size'=>5)); } On 27/10/2005, at 8:51 PM, Dan Rossi wrote:
On 26/10/2005, at 2:21 AM, Justin Patrin wrote:
I suggest if you're using FormBuilder to create the form you also do processing with it. You can always do other things with the data as well. Take a look at pre and postProcessFormCallback.
Actually, yes it will. require_once('HTML/QuickForm.php'); $form = new HTML_QuickForm(); $form->addElement('text', 'arr[]', 'Element 0'); $form->addElement('text', 'arr[]', 'Element 1'); $form->addElement('text', 'arr[]', 'Element 2'); $form->display(); "It craps out" isn't a very good explanation. What *exactly* happens. QF won't let you, for example, use the same element name for different element *types*. But it's fine in the above example.
Ok yes that works i meant in formbuilder. Anyway is there a subForm example i can work off ? In particular im not displaying a list of current records, but for the insertion page a changable list of elements to insert records into the track titles table. That is you can update how many rows/elements to display and insert hence the elementnames with [] appended to them is the best solution i think unless FB can handle it ? I may aswell just use standard html form elements inside the template ? --PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.pear.general (#21675) next »