Re: creating a single form for editing/reviewing all records in a table
| From: | Justin Patrin | Date: | Sat, 17 Sep 2005 18:33:47 +0000 |
| Subject: | Re: creating a single form for editing/reviewing all records in a table | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21015@lists.php.net to get a copy of this message | ||
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