I'm studying MVC a few days ago and I came across a question, I need a view to do registration, but this view would not do anything just send the data to my doubt is that I need a control just to put this view and another to register it?
I'm studying MVC a few days ago and I came across a question, I need a view to do registration, but this view would not do anything just send the data to my doubt is that I need a control just to put this view and another to register it?
HTTP applications change a bit compared to desktop applications, for example C ++ software that uses MVC has signal support, so even a button can be a "controller".
In the HTTP frameworks until the request, the index page must be a Controller / action, examples:
Laravel, like other more recent frameworks, uses routes to access controllers, for example:
<?php
Route::get('/', 'HomeController@getIndex');
The Controller should be something like:
<?php
class HomeController extends UserController
{
public function getIndex()
{
return View::make('formulario');//Mostra o seu view
}
}
Note that in the example the View does not receive data from the Model, but the Model form will probably access another action within the HomeController
(or other Controller) that will use a Model
.
In cakephp you should edit the app/config/routes.php
file, something like:
Router::connect('/', array(
'controller' => 'MeuController',
'action' => 'index'
));
This index
action does not necessarily need to access a Model, assuming that it contains your form
Assuming that the form points to a page as http://example/usuario/cadastrar
then you will have to add a route like this:
Router::connect('/usuario/cadastrar', array(
'controller' => 'MeuController',
'action' => 'cadastrar'
));
Or another Controller
Router::connect('/usuario/cadastrar', array(
'controller' => 'UserController',
'action' => 'cadastrar'
));