You are here

public function BaseFieldDefinition::setCardinality in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::setCardinality()
  2. 9 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;
}