- Proper validation for each field.
- Preventing duplicates.
- User friendly.
For achieve these things first we need to have a proper database structure.So following illustrate the ER diagram.
After the database design I created models for each entity in cakePHP. For that I use CLI tool provided in cakePHP. It makes life easy :) . By just typing "cake bake model" we can create a new model. CLI tool suggest appropriate models from the database. So that we can select what we want. Then tool suggest what are the things that can included in a model.Such as validations,associations(linking models) and etc.
Then we need a view to view the user form.
In next form, there is a field for select country. In order to add country list I used formHelp in view.So I created file in view/Helper and use it in the controller(new helper function name should be added to $helper array). ex- if file is LangHelper.php in controller $helpers = array('Html', 'Form','Lang', 'Session') should be added.
Here is the code for helper I added to create country drop down list
Then in view file which controller has added the helper can use helper we can create country list like this
$this->lang->countrySelect('Country');
No comments:
Post a Comment