Undefined array key "button_label" when configuring automator_text on form display
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3541933. --> Reported by: [brunodbo](https://www.drupal.org/user/33235) Related to !836 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>When I try to add the <code>automator_text</code> field widget action automator on a long text field, I get the following error in the console "Warning: Undefined array key "button_label" in /var/www/html/docroot/modules/contrib/ai/modules/field_widget_actions/src/FieldWidgetActionBase.php on line 199".</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>- Add a long plain text field to a node.<br> - Configure a field widget action on the field (see <a href="https://git.drupalcode.org/project/ai/-/blob/1.2.x/docs/modules/field_widget_actions/automators.md?ref_type=heads">https://git.drupalcode.org/project/ai/-/blob/1.2.x/docs/modules/field_widget_actions/automators.md?ref_type=heads</a>)<br> - In the second step, where you configure the automator on the form display, there is no option to configure the automator for the field. See <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai/issues/3541931" title="Status: Closed (fixed)">#3541931: Missing field_types and widget_types in automator_text field widget action</a></span> for a workaround for now.<br> - When you try to add the automator, the error is shown in the console.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>I noticed e.g. in <code>\Drupal\field_widget_actions\FieldWidgetActionBase::buildConfigurationForm</code> that a null coalescing operator is used when reading <code>$configuration['button_label']</code>, so we could do the same in <code>\Drupal\field_widget_actions\FieldWidgetActionBase::getButtonLabel()</code>:</p> <pre>public function getButtonLabel(): string {<br>&nbsp;&nbsp;&nbsp; return $this-&gt;configuration['button_label'] ?? $this-&gt;getLabel();<br>&nbsp; }</pre><p>Happy to open an MR is that seems like the right approach.</p>
issue