Skip to content
Snippets Groups Projects
Commit 234ed4f8 authored by catch's avatar catch
Browse files

Issue #2226267 by yched: Improve default value handling of fields to be consistent (follow-up).

parent 2a4c2f6b
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -380,7 +380,7 @@ public function isDisplayConfigurable($display_context) {
*/
public function getDefaultValue(ContentEntityInterface $entity) {
// Allow custom default values function.
if (isset($this->definition['default_value_callback'])) {
if (!empty($this->definition['default_value_callback'])) {
$value = call_user_func($this->definition['default_value_callback'], $entity, $this);
}
else {
......@@ -396,9 +396,10 @@ public function getDefaultValue(ContentEntityInterface $entity) {
*
* If set, the callback overrides any set default value.
*
* @param string|array $callback
* The callback to invoke for getting the default value. The callback will
* be invoked with the following arguments:
* @param callable|null $callback
* The callback to invoke for getting the default value (pass NULL to unset
* a previously set callback). The callback will be invoked with the
* following arguments:
* - \Drupal\Core\Entity\ContentEntityInterface $entity
* The entity being created.
* - \Drupal\Core\Field\FieldDefinitionInterface $definition
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment