Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BaseFieldDefinition.php

function 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;
}
RSS feed
Powered by Drupal