use Sonata\AdminBundle\Form\FormMapper; class MyAdmin extends AbstractAdmin { protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('name', 'text'); } }
use Sonata\AdminBundle\Form\FormMapper; class MyAdmin extends AbstractAdmin { protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('name', 'text', [ 'label' => 'Full Name', 'required' => false, 'attr' => [ 'class' => 'form-control' ] ]); } }In this example, the 'name' field is added to the form, with options for a label, being non-required, and having a CSS class added to its HTML input element. Overall, the FormMapper add method is part of the SonataAdminBundle package for PHP, which provides a convenient way to add form fields to form objects.