NYCPHP Meetup

NYPHP.org

[nycphp-talk] Preferred method for parsing multi-row submitbuttons

Glenn glenn310b at mac.com
Tue Nov 22 12:45:42 EST 2005


How about encoding all form widgets with
form_row info, including an action widget/s for each
row.  (a select with an "Ignore" or "Skip" option selected
by default works for me).

You can encode the widget names to allow
grouping by table_row_action, pretty much anything.

Explode each widget key and set up a multidimensional
associative array.

One submit button will process the whole form.

If it's a dynamic form, create a unique name for it and create
a plain text tmp file using the form name.

Write copies of your auto-generated form widget names
to the tmp file.

As someone else said, if the tmp file doesn't exist when
the form is submitted, then the form has already been processed.

When you process the form, compare the widget names
from the form to the widget names in the tmp file.

If they don't match exactly, it's a form error.

Of course all the usual validation needs to be done as well...

After the form is processed, delete the tmp file.

Glenn

On Nov 21, 2005, at 3:48 PM, Cliff Hirsch wrote:

> Yes, I thought of that and a form per row sure would be the easiest way
> to go. But I want to have the flexibility to add checkboxes to each 
> row,
> if required, which would facilitate global, "do action to all checked"
> buttons.
>
> I just do something like this:
>
> foreach($_POST as $key => $value) {
> 	if (substr($key,0,6) == "submit") {
> 		$temp = explode("_", $key);
> 		$action = $temp[1];
> 		$row = $temp[2];
> 		break;
> 	}
> }
>
> It works -- just wondering if there's a better way.
>
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org 
> [mailto:talk-bounces at lists.nyphp.org]
> On Behalf Of Jeff Loiselle
> Sent: Monday, November 21, 2005 3:29 PM
> To: NYPHP Talk
> Subject: Re: [nycphp-talk] Preferred method for parsing multi-row
> submitbuttons
>
> Make each row its own form?
>
>  _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>




More information about the talk mailing list