public function BaseFieldDefinition::setCardinality in Drupal 9
Same name and namespace in other branches
- 8 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\FieldCode
public function setCardinality($cardinality) {
$this->definition['cardinality'] = $cardinality;
return $this;
}