use Sonata\AdminBundle\Form\FormMapper; class FooAdmin extends AbstractAdmin { protected function configureFormFields(FormMapper $formMapper) { $formMapper ->tab('General') ->with('Category') ->add('category', 'entity', [ 'class' => 'AppBundle\Entity\Category' ]) ->end() ->end(); } }
use Sonata\AdminBundle\Form\FormMapper; class BarAdmin extends AbstractAdmin { protected function configureFormFields(FormMapper $formMapper) { $formMapper ->tab('General') ->with('Details') ->add('name', null, [ 'label' => 'Name' ]) ->add('description', 'textarea', [ 'label' => 'Description' ]) ->end() ->with('Images') ->add('images', 'sonata_type_collection', [ 'type_options' => [ 'delete' => true ] ]) ->end() ->end(); } }In this example, we are using the FormMapper class to create a form with two tabs: "General" and "Images". Within the "General" tab, we have defined two fields: "name" and "description". Within the "Images" tab, we have added a collection of images using the "sonata_type_collection" field type. This allows us to add/remove images as needed, and provides a checkbox to delete existing images. The package library used in these examples is the Sonata AdminBundle, which is a Symfony bundle that provides CRUD functionality for managing entities in the Symfony framework.