-
Notifications
You must be signed in to change notification settings - Fork 0
Creating form views
If everything went alright you've already created a list view. If not, read more about that here.
To create a form view, again open the app/admin/PostAdmin.php
file, but rather than go to the configureList()
method, take a look at the configureForm()
method.
This method again gives you a mapper instance, the FormMapper
instance to be exact this time. This instance almost works the same as the previous ListMapper
instance with some minor differences.
To create our basic form view for our blog, we want to something like the following:
- A text field for the title
- A textarea field for the body
- A select field for both the author and the category.
Right now, we'll just focus on creating the first to fields because the other fields have some further work for you to do, so we'll just focus on the title and body.
Edit the configureForm()
method to something like the following:
public function configureForm($mapper)
{
$mapper->text('title');
$mapper->textarea('body');
}
Now, click the create new post
button and see your simple form automagically being created.
It's just that simple.