Entity inherits all functionality from Choice type, with additional options:

  1. class (String) (Default: null) - Full path to the Model class that will be used to fetch choices.
  2. query_builder (Closure) (Default: null) - If provided, used to filter data before setting as choices. If null, gets all data.
  3. property (String) (Default: name) - Property from model that will be used as label for options in choices
  4. property_key (String) (Default: id) - Property from model that will be used as value for options in choices

Note: If choices are provided in options, class option is ignored, and passed data for choices is used.

<?php
    $this->add('languages', 'entity', [
        'class' => 'App\Language',
        'property' => 'short_name',
        'query_builder' => function (App\Language $lang) {
            // If query builder option is not provided, all data is fetched
            return $lang->where('active', 1);
        }
    ]);