I want to display a form that I made up using the cake bake console command in my homepage. How do I go about that? I remember I did that in CakePHP 2.x by using elements, but it seemed a little not DRY. It’s a little form with a name, country, email, and comments textboxes that the user has to fill up.
In total, I am going to display two apps in the homepage. Each of them with records in the model.
By app I mean one which has a model, view and a controller.
I have a CRUD application, I want to display the add controller where you fill out the form, in the homepage. Basically I want to display a form in the homepage. I’ve been reading about cells, and I think it’s the way to go, but I wont show anything.
Okay, so you basically meant “cell” when talking about “app”
I haven’t had any reason to use cells so far, but yes, if the form is supposed to be populated with data, or some other kind of logic is required, cells should be right tool for the job (but if the form is always empty at first, an element would be completely sufficient).
You should probably post the code you have so far, since it’s hard to know what’s wrong otherwise.
In that case an element should be the much simpler solution.
A cell makes sense if you need to create a view that consists of data from models/controllers.
So for example, if you have a block with information about a movie, it needs to get data from a movies table, an actors table, a ratings table, etc. which is then processed and sent to the view.
Without a cell, creating such a block for multiple different methods would be very un-DRY, since you’d have to fetch and process the data in every single method. With a cell, you only need to do it in one place.
However, this isn’t necessary for a simple form, since you can always use the same action no matter where you show your form. Just explicitly define the action that handles the form and it should work no matter where you include the form element.