On 09/28/2002 12:56 AM, Peter J. Schoenster wrote:
>>Assumming that you tried the forms generation and validation class, what
>>did you realize that was missing to match your needs?
> Well that's the first thing I found and I downloaded it. It does much 
> more than what I want, for instance here:
>> $subscription->AddInput(array(
>>  "TYPE"=>"text",
>>  "NAME"=>"email",
>>  "MAXLENGTH"=>100,
>>  "Capitalization"=>"lowercase",
>>  "ValidateAsEmail"=>1,
>>  "ValidationErrorMessage"=>"It was not specified a valid e-mail
>>  address"
>> ));
> Those attributes already exist in the form. I create the forms on the 
> fly only once afterwhich they are in the hands of the designers to 
> manipulate. I pass back to the form a data structure that will have 
> something like:
> missing_email
> invalid_email
> and the designer can check for this, lke this in smarty:
> {if $error.missing_email}Yo give me email{/if}
> {if $error.invalid_email}Please verify your email{/if}
> and I have a script that will generated those if statements so one 
> doesn't need to do a lot of typing. 
> I don't like generating the form programmatically all the time ... I 
> leave that to the *view*. 

I understand that you want a more productive development process, but I 
don't agree with the reasoning. Form layout is presentation logic but 
validation is business logic. The designer should not be required to 
understand the business logic. As a matter of fact the designer should 
not even be required to know HTML, I mean in the perfect world.

> I just want to pass the input data I received, the definition of the 
> form I'm using with this data and have the function return the 3 arrays 
> : good, invalid, missing. I've been very happy with this in Perl. 
> The formgen is very powerful, too powerful and too intrusive into the 
> other things I'm doing. I only need a small part of it. What I want has 
> nothing really to do with html forms, just data validation.

Yes, but you probably want client side validation to avoid the user 
going through the pain of an extra server round trip to tell him that a 
field is invalid, some times the validation logic is contextual, like 
you when the user needs to set at least one of several radio buttons, etc..

There is no way to achieve this with mixing the presentation logic with 
the business logic.

Currently, the way my class is, it is not very practical because you 
would need to mix the presentation and business logic by hand. I have my 
methods that completely isolate both logic using this class but that 
requires an external a meta-programming language that will generate the 
code that achieves that, in a way that is much more efficient than using 
Smarty. If you are interested, that is available here:


However that language is no longer PHP as you hoped. Currently it is 
also not very usable because I have had not the time to document it.

Anyway, I am working on something else based on the forms class that I 
think will be more like what you need. Basically you just feed it the 
HTML that the designer produced and it automatically will figure where 
the fields and labels are to compose the form. You may still use Smarty 
to adjust the form presentation depending on the results of an eventual 
validation request. Stay tuned.


Manuel Lemos

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

Reply via email to