function BaseFieldDefinition::setCardinality

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::setCardinality()
  2. 10 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::setCardinality()
  3. 11.x core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::setCardinality()

Sets the maximum number of items allowed for the field.

Possible values are positive integers or FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED.

Note that if the entity type that this base field is attached to is revisionable and the field has a cardinality higher than 1, the field is considered revisionable by default.

Parameters

int $cardinality: The field cardinality.

Return value

$this

File

core/lib/Drupal/Core/Field/BaseFieldDefinition.php, line 278

Class

BaseFieldDefinition
A class for defining entity fields.

Namespace

Drupal\Core\Field

Code

public function setCardinality($cardinality) {
    $this->definition['cardinality'] = $cardinality;
    return $this;
}

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