From 2cc1f2bcac698b29f46b147c426636bf43d29ed4 Mon Sep 17 00:00:00 2001 From: Dieter Holvoet Date: Thu, 31 Mar 2022 14:58:23 +0200 Subject: [PATCH] field-create: Fix default value if show-machine-names option is off --- 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