From 7fd5b1079c8610613501607d603f30b783af65c3 Mon Sep 17 00:00:00 2001 From: Dieter Holvoet Date: Sun, 3 Apr 2022 14:28:10 +0200 Subject: [PATCH] field-create: Fix default value if show-machine-names option is off (#5110) Co-authored-by: Moshe Weitzman --- src/Drupal/Commands/field/FieldCreateCommands.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Drupal/Commands/field/FieldCreateCommands.php b/src/Drupal/Commands/field/FieldCreateCommands.php index 412100a894..f892f0115d 100644 --- a/src/Drupal/Commands/field/FieldCreateCommands.php +++ b/src/Drupal/Commands/field/FieldCreateCommands.php @@ -315,7 +315,9 @@ protected function askFieldWidget(): string $choices[$name] = $label; } - return $this->io()->choice('Field widget', $choices, key($choices)); + $default = $this->input->getOption('show-machine-names') ? key($choices) : current($choices); + + return $this->io()->choice('Field widget', $choices, $default); } protected function askRequired(): bool