When I try to add a phone number to an Organization contact, I get an error and then the Phone widget turns into a second Address widget

Created on 27 August 2025, 6 days ago

Problem/Motivation

Organization form doesn't let me enter phone numbers and outright replaces the field if I keep clicking

Steps to reproduce

1) I start creating an Organization contact
2) I enter the Name 'TestOrganization1'
3) I click the 'Add new telephone' button
4) I enter Type 'Main' and Telephone '555-555-5555'
5) I click 'Create Telephone'
5) I see the form throw the error 'Oops, something went wrong. Check your browser's developer console for more details.'. When I check the console I see:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /crm/contact/12/edit?ajax_form=1&_wrapper_format=drupal_ajax
StatusText: error
ResponseText: The website encountered an unexpected error. Try again later.Error: Object of class Drupal\telephone\Plugin\Field\FieldType\TelephoneItem could not be converted to string in Drupal\crm\Entity\ContactDetail\TelephoneContactDetail->label() (line 21 of /var/www/html/src/Entity/ContactDetail/TelephoneContactDetail.php). Drupal\inline_entity_form\Form\EntityInlineForm->getEntityLabel() (Line: 372)
Drupal\inline_entity_form\Plugin\Field\FieldWidget\InlineEntityFormComplex->formElement() (Line: 464)
Drupal\Core\Field\WidgetBase->formSingleElement() (Line: 101)
Drupal\Core\Field\WidgetBase->form() (Line: 595)
Drupal\inline_entity_form\Plugin\Field\FieldWidget\InlineEntityFormBase->form() (Line: 197)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm() (Line: 121)
Drupal\Core\Entity\ContentEntityForm->form() (Line: 81)
Drupal\crm\Form\ContactForm->form() (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm()
call_user_func_array() (Line: 528)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 370)
Drupal\Core\Form\FormBuilder->rebuildForm() (Line: 625)
Drupal\Core\Form\FormBuilder->processForm() (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 715)
Drupal\Core\DrupalKernel->handle() (Line: 19)

6) I click 'Create Telephone' again, and the phone widget changes into the address widget. See screenshot attached to ticket

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada speckles

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

Comments & Activities

  • Issue created by @speckles
  • πŸ‡¨πŸ‡¦Canada speckles

    Note - when I edited a Contact and tested the telephone field on it I saw the same behaviour

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    Are you using the latest dev release?

    This sounds very similar to πŸ› Error prevents adding phone number to contact Active

  • πŸ‡¨πŸ‡¦Canada speckles

    No - I checked out a smoke test branch to keep things consistent while I was planning out smoke tests.

    I would argue that "The telephone widget can become a second address widget if there's an error", as shown in my screenshot, counts as a new bug however. I'm okay if the resolution is Do Not Fix, but having a discussion thread someone can find if the problem pops up again because of a new error still seems worthwhile to me.

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    No - I checked out a smoke test branch to keep things consistent while I was planning out smoke tests.

    You should only report bugs after you have confirmed it exists in the latest dev branch, and have not already been reported.

  • πŸ‡¨πŸ‡¦Canada speckles

    This bug would not happen in the latest branch since it's a bug in how the system responds when the form has a bug. You would have to modify the code to throw an error in the same place that was fixed to recreate the bad behaviour

    Like I said before, maybe it's better to just leave the landmine in the code until the next bug happens. But it is problematic error handling behaviour.

  • πŸ‡ΊπŸ‡ΈUnited States jdleonard Austin, TX, USA

    When there are errors and AJAX involved, sometimes weird stuff happens. I don't think that's something that CRM can reasonably control. But certainly any bug that's caused by CRM should have an issue filed.

    I'll echo @bluegeek9 that potential bugs should be verified against the latest dev branch (note that's what the Version field's "1.0.x-dev" value represents) prior to being created as an issue. This allows maintainers to focus on actionable issues.

    Setting status to reflect that this can't be reproduced in the latest dev branch.

Production build 0.71.5 2024