Contact module recipent field raising issue on ajax fields for Module contact_mail_formatter

Created on 3 June 2024, 8 months ago

Problem/Motivation

Steps to reproduce

Module: https://www.drupal.org/project/contact_mail_formatter
Code branch: https://git.drupalcode.org/project/contact_mail_formatter/-/tree/mailer_...

TypeError: implode(): Argument #1 ($array) must be of type array, string given in implode() (line 96 of /app/web/core/modules/contact/src/ContactFormEditForm.php).

$form['recipients'] = [
      '#type' => 'textarea',
      '#title' => $this->t('Recipients'),
      '#default_value' => implode(', ', $contact_form->getRecipients()),
      '#description' => $this->t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com' . To specify multiple recipients, separate each email address with a comma."),
      '#required' => TRUE,
    ];

Proposed resolution

'#default_value' => implode(', ', $contact_form->getRecipients()),

needs to be changed

'#default_value' => (is_array($contact_form->getRecipients()))? implode(', ', $contact_form->getRecipients()) : $contact_form->getRecipients(),
🐛 Bug report
Status

Active

Version

10.4

Component
Contact 

Last updated 1 day ago

Created by

🇮🇳India jitendra verma Delhi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jitendra verma
  • Status changed to Postponed: needs info 8 months ago
  • Why is it necessary to change Drupal core here rather than have your module respond to getRecipients with an array?

  • 🇮🇳India jitendra verma Delhi

    @cilefen Thanks for your reply.
    As in the contact module used the implode method, when fresh from load it gives an array, but when form rebuilds it gets data from the direct field which is strig that why my Ajax call was broken, if we can add there a check for array it will resolve Issue .

    if there is any other solution that I can use to solve my problem, Please help

  • Status changed to Active 7 months ago
  • 🇳🇿New Zealand quietone

    @Jitendra verma, this is now a support request and the Drupal Core issue queue is not the ideal place for support requests. The 'support request' option is there for filing support issues for contributed modules and themes. There are several support options listed on our support page (Community > Support at the top of Drupal.org) and there is Drupal Slack . You may get better replies in one of those places.

Production build 0.71.5 2024