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

[eluser]chuckleberry13[/eluser]
Thanks for sharing that JoostV. I might look into it sometime but last night I setup the controller handling the form to take in an extra argument which will make it a view partial and I think I like that setup the best for now and here is my reason. I can easily include that form anywhere with one line of code in any of my views like this.

Code:
//Parameter 1 is the controller containing the form
//Parameter 2 is where the form will redirect if it passes validation. If it fails validation it re-displays the form with the entered data and validation errors.
//Parameter 3 is the function inside the controller that contains the form/view partial

<?= modules::run('controller', 'account/will_retire/2', 'signup') ?>

This way its one line, and the validation and form processing is handled in one central location with no extra work. If anybody sees how this could be a problem I wouldn't mind discussing it.

The reason I like this over creating a library to handle forms is I don't have to add anything to the library every time I add a form element. Maybe I misunderstood your library but you do have to do that right?


Messages In This Thread
best practices on Form Reuse - keeping all forms in a central location with validation - by El Forum - 07-25-2008, 09:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB