By ajeyashetti
I am a new learner to cakephp Required help in 1 project
I have 2 forms event and category both required to store in different table.
I have can save data for event form using event model and store in event table using maincontroller
I want category form to save in category table using maincontroller and category model
how can I do it.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I have figured it out
My goal was when I trying to save 2 seperate forms event and category it must redirect to index page after saving the records in the table
I had events folder for views -> add_event, add_category, index
so both are forms required to store in diff tables i.e. event table and category table
I had 2 models event and category
I wanted to use only 1 controllers EventsController which can do 2 actions addEvent and addCategory
I could save and redirect to index for “event” but it was not working for adding “category”
cause when the form goes to controller for submission I cannot save the data must due to loading of table for category action.
so I created a empty function for addcategory which is required since category form is in events folder
and created a new controller called CategoriesController where I redefined the actions for addCategory $this->Model->save()
Here the problem of creating a new controller was the url will be proj/categories/addCategory
so since it is in categories/ it wont redirect to index page.
so I used relative paths i.e …/events/index then returned back after saving category to index page.
Thank you
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.