It’s gonna be a form tutorial
- Posted by dlib on March 20th, 2008 filed in Form tutorial, Tutorials
In my previous post I asked for suggestions for a tutorial. My expectation was a tutorial on ORM relationships but there was a general consensus towards a tutorial of forms and validation. I’ll cover the ORM relationships in some mini-tutorials in the future, I think that’s easiest.
The forms and validation tutorial I will probably cover in more than one post. I’ve set myself several goals of what the tutorial should cover. The end result for the tutorial is a validating form with database inserts and updates using ORM. The first goal is that I’ll utilize several methods to roughly accomplish the same end result, I’ll use Kohana’s new validation library, Forge and my very own Formation to do validation and if applicable generate the forms. I do intend to use each method’s strengths to give you the picture of which approach might suit you best.
I’ll use ORM, Forge and the new validation library as they are currently available in svn. I will try to limit the amount of own libraries using the MY_* syntax but if I do I’ll supply them. Regarding uploads and setting relationships in the form, the tutorial would become rather big if I included this. I hope to cover these topics in a follow-up.
The form we’ll be trying to create needs to do a couple of things:
- Name field - all names should be capitalized and names cannot be longer than 50 characters
- Email field - must satisfy as an email
- Checkboxes for food preference( pizza, spaghetti, French fries and Sauerkraut)
- Textarea - for comments
- Submit button
I’ll save the food preferences as a serialized array in the database to avoid complexities of relationships in the form. As stated above, I hope to cover this at a later stage. The goal should be for new users to understand what’s happening so we better take one step at a time.
The forms should be reusable for the edit and the insert method in the controller.
I hope to finish the tutorial sometime this week.
Edit: Working on the tutorial I decided to split it over several different posts. It’s proven to be quite some work. I’ll first do simple inserts with forms.
March 20th, 2008 at 2:46 pm
Name, email, textarea is too simple. Maybe add image upload (like avatar - upload and resize to 80×80). Personaly i hate ORM so i hope that tutorial show me how to do this in normal way
Thank you for your time. Good job!
March 20th, 2008 at 3:22 pm
I think I’ll handle image uploads in a follow-up, I have not yet any real usage for image handling in my projects so it will be quite a hassle for me to get properly acquainted with it.
I chose ORM because it can keep me on the right track of explaining forms and validation. Otherwise I’d have to thoroughly explain models as well. Again, this may be addressed in future posts but I’d like to keep this tutorial short and comprehensible.
As I am writing this tutorial it already is quite a lot of work so I’d rather split the task over several posts
March 20th, 2008 at 4:31 pm
cool! Can’t wait to see it! By the way, your entries feed seems to be broken.
March 20th, 2008 at 4:51 pm
This sounds great! I’m looking forward to it. As you mentioned above, this could be an excellent base for future tutorials to build upon — you could expand upon the same views and forms in this tutorial to integrate uploading, relationships, models, etc. for future articles.