Entity

Use the entity type for relations to other entities.

For example, suppose a Pet entity has an owner, a manyToOne doctrine relation to a User entity. You would use the entity type on the owner property to give a pet an owner.

Collections of entities can be managed too - set the multiple option to true.

Note that sorting will not work out of the box. You’ll need to define a custom sort function if you want to sort by this field.

Included in the PerformBaseBundle.

Options

class

The related entity class

This option is required.

Allowed types: string

Defaults:

  • List context: No default
  • View context: No default
  • Create context: No default
  • Edit context: No default

crud_name

The crud name to use for the related entity

This option is optional.

Allowed types: string

Defaults:

  • List context: ''
  • View context: ''
  • Create context: ''
  • Edit context: ''

display_field

The property to use to display the related entity

This option is optional.

Allowed types: string

Defaults:

  • List context: 'id'
  • View context: 'id'
  • Create context: 'id'
  • Edit context: 'id'

label

The label to use for form labels and table headings. If no label is provided, a sensible label will be created automatically.

This option is optional.

Allowed types: string

Defaults:

  • List context: No default
  • View context: No default
  • Create context: No default
  • Edit context: No default

multiple

If true, assume the relation is a doctrine collection

This option is optional.

Allowed types: boolean

Defaults:

  • List context: false
  • View context: false
  • Create context: false
  • Edit context: false

Example

<?php
$config->add('owner', [
    'type' => 'entity',
    'options' => [
        'class' => 'PerformUserBundle:User',
        'display_field' => 'email',
    ],
    'sort' => false,
]);