Re: Creating forms dynamically

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

on 03/14/2006 05:21 PM Paul Goepfert said the following:
> I have been working on a page where I have a form.  I currently have
> the form in an else block with no access to it if I need to redisplay
> the form incase of errors. To be more specific I want to redisplay the
> page with the errors displayed. I would like to have the form coded
> once.  It would save on file size.  In my form I have a table that
> holds the text inputs.  I do have MySQL code for dropdown menus.  If
> anyone has any ideas on how to create the form when the error messages
> are displayed without having to code it a second time please let me
> know.

Why don't you just use the same script to display and process the form?

Just set the form action attribute to an empty string and you do not
even have to figure what is the current page URL.

I always do that precisely for the reasons you mentioned of the form
having invalided fields that need to be corrected by the user.

I also use this popular class for forms generation and validation. I
just specify which kinds of validation I want and the class validates
the form for me on the server side. It also generates automatic
Javascript code to perform validation on the browser side before the
user submits the form to reduce the need to access the server to perform
validation.

Now there is even something better. The class comes with an AJAX form
submission plug-in that lets the form be validated without reloading the
page.

If there are invalid fields, your script can command the forms class
with that plug-in to mark the fields that are invalid.

If the form is completely valid, you can process the form actions and
give feedback to the user browser while the form processing occurs on
the server side. When all is done you can tell the class to show a
success message, wait a few secons and redirect the browser to a new page.

The good part is that this works well with all browsers and you do not
need to know a single bit of Javascript to implement this.

Take a look in particular to the test_ajax_submit.php example.

http://www.phpclasses.org/formsgeneration


PS. the class also comes with another plug-in to link multiple dropdown
(select) inputs loading options taken from a database.

http://www.phpclasses.org/browse/view/html/file/9879/name/test_linked_select_page.html

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux