Welcome Guest, Not a member yet? Register   Sign In
best practices on Form Reuse - keeping all forms in a central location with validation
#24

[eluser]Colin Williams[/eluser]
Quote:That way if I include the same field but in another form its validation rules/callback function is triggered. I am thinking I can just set a bank of validation rules and test if that field was passed in and if so attach its validation rule to the $rule array.

Not a bad idea. You're essentially building a system of form widgets. I think a well thought-out form widget library could be in order for that. The only concern is that it would lock you into strict conventions (although convention over configuration is all the rage, if the convention doesn't extend all the way through the process, your just creating more work somewhere else). Rules are already fairly simple to define, but it's that extra processing that current rule functions can't do by themselves that might be useful.

Quote:a form is a form is a form...it is not locked to a controller or a view or an application or a panel or the left side or middle or top of a page

I don't think I was speaking to the contrary. But I'm not sure I can imagine a single form shared among Controllers. Even if it had the exact same field names and HTML markup, it's going to serve an individual purpose. And what happens when one Controller requires more from the form? You've got to go ahead and make yourself two separate forms anyway. Feel free to prove me wrong by example.


Messages In This Thread
best practices on Form Reuse - keeping all forms in a central location with validation - by El Forum - 07-24-2008, 11:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB