Field label not configurable from the UI and it's set from the module as street instead of Phone number or any related label title.

Label issue

Comments

mqanneh created an issue. See original summary.

mqanneh’s picture

Assigned: mqanneh » Unassigned
Status: Active » Needs review
StatusFileSize
new1.24 KB

Changed field label from street into Phone number

mqanneh’s picture

StatusFileSize
new32.11 KB
mqanneh’s picture

Issue summary: View changes
StatusFileSize
new6.01 KB
mqanneh’s picture

Category: Task » Feature request
Priority: Normal » Minor
riddhi.addweb’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new61.06 KB
new60.33 KB

@mqanneh, Thanks for the correction, It works well for me As I checked it using Simplytest.me also attached screenshot for same.

hugronaphor’s picture

Status: Reviewed & tested by the community » Needs work

There is no need at all to add #title nor #description property!
Just remove those and you're going to get the configured values from the field instance.

mqanneh’s picture

Status: Needs work » Needs review

@hugronaphor kindly check the patch again. The patch didn't add #title or #description properties it just changed the #title value as below:

-      '#title' => $this->t('Street'),
+      '#title' => $this->t('Phone number'),
hugronaphor’s picture

Yes, I do understand this.

But what if I want to have the label as "Telephone"? It should have the title I've configured on my field in UI.
It should be something like:

$element['value'] = $element + [
        '#type' => 'textfield',
        '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
        '#attributes' => ['class' => ['international_phone-number']],
        '#attached' => [
          'library' => ['international_phone/international_phone'],
        ],
  ];

#title is already populated in $element

randell’s picture

I created a patch based on Comment #9, which I've also tested on Drupal 8.5.5. It works the way regular field labels should work, which should be updatable.

hitchshock’s picture

Status: Needs review » Reviewed & tested by the community

It's working for me.

randell’s picture

What's the next step in getting this patch released ?

  • randell authored 0316734 on 8.x-1.x
    Issue #2915431 by mqanneh, randell, riddhi.addweb: Fix field label
    
mayurjadhav’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.