Re: Forms validation and creation- easier solution?

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

 



Viva,

on 05/22/2009 10:36 AM Paul M Foster said the following:
>> IMHO, creating forms by hand is by no means simpler, especially if you
>> want to include browser side (Javascript) validation.
>>
>> I mean, I am not masochist to create something that will give me more
>> work in the end to develop PHP forms based applications than if I would
>> type HTML manually.
>>
>> Furthermore, the plug-ins that come with the package dramatically reduce
>> the amount of code you need to type to achieve the same generating
>> common HTML inputs manually.
>>
>> Anyone can judge by yourself by going here and see several example forms
>> and the actual code that it takes to generate them:
>>
>> http://www.meta-language.net/forms-examples.html
>>
>> For instance this scaffolding plug-in generates CRUD forms that you
>> often need to manage data stored for instance in databases.
>>
>> http://www.meta-language.net/forms-examples.html?example=test_scaffolding_input
>>
>> For those interested to check it out, the actual class package can be
>> downloaded from here:
>>
>> http://www.phpclasses.org/formsgeneration
>>
>> Here you may watch an extensive tutorial video that covers practically
>> all features:
>>
>> http://www.phpclasses.org/browse/video/1/package/1.html
>>
> 
> 
> Here's what I was talking about. Assuming you simply type out your form
> fields like this:
> 
> <input type="text" name="address" size="30" value="123 Main St."/>
> 
> Now, if you do it with a class like yours:
> 
> $arr = array('type' => 'text',
>             'name' => 'address',
>             'size' => 30,
>             'value' => '123 Main St.');
> 
> $form->AddInput($arr);
> 
> (I haven't looked at your class in a while, so I may have invoked it
> slightly incorrectly.)
> 
> If you compare the typing involved in the first case with the typing
> involved in the second case, you can see that it's more in the second
> case.

That is because you are just thinking about the typing of the generated
HTML. To generate and validate forms, you also have to consider the code
you write to validate and process the forms because the HTML forms do
not process by themselves.

You need to think about the security of your application, so you also
need to validate submitted values, discard invalid values, escape
outputted values, and so on. All that is done with a couple of calls to
the forms class.


> Yes, your forms generation class includes a tremendous amount of proven
> code, including a bunch of Javascript validation, all of which the
> programmer doesn't have to develop himself.
> 
> The only real complaint I have about your class is that the class file
> itself (forms.php) is 158+ K bytes, which must be loaded every time you
> surf to a page for the first time.

That used to be an issue in the 20th century in the PHP 3 days. Since
PHP 4, the PHP code is no longer interpreted. The Zend engine compiles
the PHP code in Zend op codes in the first stage. In the second stage
the op codes are executed. If you use a cache extension like APC, Turck
MMCache, XCache, etc.. the first step is skipped after the first
execution and the size of the original code is not relevant because it
is already compiled in shared memory.

Anyway, the class has all that code because it is necessary to implement
all it supports.

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

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