public FieldConfigBase::setDefaultValue($value)
Sets a default value.
Note that if a default value callback is set, it will take precedence over any value set here.
mixed $value: The default value for the field. This can be either:
$this
Overrides FieldConfigInterface::setDefaultValue
public function setDefaultValue($value) { if (!is_array($value)) { if ($value === NULL) { $value = []; } $key = $this->getFieldStorageDefinition()->getPropertyNames()[0]; // Convert to the multi value format to support fields with a cardinality // greater than 1. $value = array( array($key => $value), ); } $this->default_value = $value; return $this; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!FieldConfigBase.php/function/FieldConfigBase::setDefaultValue/8.1.x