Version

Documentation » Doctrine2 PHPCR Admin

« 4. Filter Field Definition

This Page

« 4. Filter Field Definition

5. Form field definition

5.1. Short Object Placeholder

When using Many-to-One or One-to-One relations with Sonata Type fields, a short object description is used to represent the target object. If no object is selected, a ‘No selection’ placeholder will be used. If you want to customize this placeholder, you can use the corresponding option in the form field definition:

namespace Sonata\NewsBundle\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Form\FormMapper;

final class PostAdmin extends AbstractAdmin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('enabled', null, ['required' => false])
            ->add('author', 'sonata_type_model_list', [], [
                'placeholder' => 'No author selected',
            ]);
    }
}

This placeholder is translated using the SonataAdminBundle catalogue.

Found a typo? Something is wrong in this documentation? Just fork and edit it!