Re: creating a single form for editing/reviewing all records in a table
| From: | Justin Patrin | Date: | Sun, 18 Sep 2005 18:08:32 +0000 |
| Subject: | Re: creating a single form for editing/reviewing all records in a table | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21026@lists.php.net to get a copy of this message | ||
On 9/17/05, Wesley Furgiuele <wesley@furgiuele.net> wrote:
> Actually, one follow-up question. Is it possible to have
> DB_DataObject return an object that holds more than one row?
Yes and no. You can run a query on DB_DO which returns more than one
record. Then you just run a fetch() loop to get them all. The same DO
ends up holding all of the data, but you get all of the records.
> For this
> application, performance is not really a major issue -- functionality
> is more important. Still, it looks like my loop would have to be:
>
> get DB result set for query of all primary keys
> foreach PK in result set {
> create new DB_DataObject object
> get single row based on primary key
> create FormBuilder object
> add elements from DB_DataObject single row
> prefix element names
> }
> display FormBuilder form
>
> So I would have to run a bunch of queries to generate the form rather
> than being able to use that initial result set. Any way to improve on
> that efficiency?
>
> I haven't looked inside DataObject yet -- just wondering if I'm
> heading in the right directory. Thanks again for any help.
If you already have a query returning all of your records just loop
over them, clone the DO, then use FormBuilder on the clone.
>
> Wes
>
>
>
> On Sep 17, 2005, at 2:33 PM, Justin Patrin wrote:
>
> > On 9/17/05, Wesley Furgiuele <wesley@furgiuele.net> wrote:
> >
> >> My current process is this:
> >> - Get all rows from a table
> >> - Display each row with a link to edit a single row's values if
> >> necessary
> >> - If the row is selected for editing, use DB_DataObject +
> >> DB_DataObject_FormBuilder to generate a form with the proper fields/
> >> validation
> >>
> >> What I would like to do is eliminate the limitation of updating only
> >> one row at a time and instead generate a page that functions probably
> >> more like a spreadsheet -- a single form where each row is displayed
> >> with form fields and a single update button. The update would then
> >> check to see if each row needs to be altered and, if so, do the
> >> database update.
> >>
> >> From what I can tell, DB_DataObject is good for a row at a time. Are
> >> there any manipulations or any other packages that are already being
> >> used to do this? I guess what I am really looking for is a package
> >> that will take the place of me writing a routine to pre-process all
> >> the form fields (to manipulate the field names so they are unique for
> >> each row) as well as something that will take care of post-processing
> >> the form data.
> >>
> >> Thanks for any pointers.
> >>
> >>
> >
> > FormBuilder has two options to help you to handle this.
> > elementNamePrefix and elementNamePostfix. If you set one or both of
> > these options with a unique identifier (like a sequence of number or
> > the PK of the record) then you can have multiple FormBuilder forms in
> > one actual form. Then you can use useForm() to have FormBuilder add
> > form values to a previous form. Then you just keep an array of all of
> > the FormBuilder objects and loop through them, calling processForm on
> > each one.
> >
> > --
> > Justin Patrin
> >
> >
>
>
--
Justin Patrin