function FieldStorageConfigEditForm::getEnforcedCardinality

Same name in other branches
  1. 9 core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::getEnforcedCardinality()
  2. 10 core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::getEnforcedCardinality()
  3. 11.x core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php \Drupal\field_ui\Form\FieldStorageConfigEditForm::getEnforcedCardinality()

Returns the cardinality enforced by the field type.

Some field types choose to enforce a fixed cardinality. This method returns that cardinality or NULL if no cardinality has been enforced.

Return value

int|null

2 calls to FieldStorageConfigEditForm::getEnforcedCardinality()
FieldStorageConfigEditForm::buildEntity in core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
Builds an updated entity object based upon the submitted form values.
FieldStorageConfigEditForm::getCardinalityForm in core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php
Builds the cardinality form.

File

core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php, line 249

Class

FieldStorageConfigEditForm
Provides a form for the "field storage" edit page.

Namespace

Drupal\field_ui\Form

Code

protected function getEnforcedCardinality() {
    
    /** @var \Drupal\Core\Field\FieldTypePluginManager $field_type_manager */
    $field_type_manager = \Drupal::service('plugin.manager.field.field_type');
    $definition = $field_type_manager->getDefinition($this->entity
        ->getType());
    return isset($definition['cardinality']) ? $definition['cardinality'] : NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.