When adding a field to a content-type, if you enter a Label, then hit tab or click on the field to share, the value in "Label" is deleted. This is kindof annoying because Label field is required :) Actually, if you go back to Label, and fill it in, then click "save" without exiting the field, you can work around this.

Comments

lyricnz’s picture

(note: previous comment didn't say this: but bug is for *existing* field only)

yched’s picture

The intended behavior is that the 'Label' input gets pre-populated with the label of the selected "existing field".

lyricnz’s picture

It looks like Drupal.settings.fields[xxx].label is NULL, I'm looking into why now.

lyricnz’s picture

Long story short, FIELD INFO doesn't appear to contain labels, only INSTANCES of fields do. The way the existing-field dropdown works is that it uses the FIRST label found for a given field. We can modify the JS to do the same (I'll submit a patch soon), but this functionality is a bit grotty, from a usability perspective.

lyricnz’s picture

Status: Active » Needs review
StatusFileSize
new3.1 KB

See attached patch. I've refactored field_ui_existing_field_options() into a utility function, and a wrapper; then used the utility function to get the labels/widgets needed for the javascript.

Please review carefully! I only started using D7 yesterday :)

eg: should the field info constructed have the t(label) or the raw label?

lyricnz’s picture

StatusFileSize
new3.15 KB

Reroll, and diff from the root directory.

retester2010’s picture

#6: existing_field_ui.patch queued for re-testing.

yched’s picture

Strange, I can't seem to apply ?

yched’s picture

StatusFileSize
new3.81 KB

DOh, I overlooked the date on #6.

Rerolled, and fixed / reorganized a bit. Should work ok now.

Steps to reproduce :
- On a default install, go to admin/structure/types/manage/page/fields ('Manage fields' for 'Page' node type)
- 'Add existing field' row shows two potential fields to add : field_image, field_tags (defined for 'article' but not for 'page')
- when you select one of those,
the 'Label' input should get populated with the Label of the existing instance,
the 'Widget' select should be updated to show widgets for the corresponding field type (image or taxo_term) [edit: forget it, that part works], and should be prepopulated with the widget used by the existing instance.

None of the two work currently. I don't know at which point this got broken. Note that this is JS-only, so there's no writing tests for this.

yched’s picture

Priority: Normal » Critical

[edited out]

yched’s picture

Priority: Critical » Normal

nevermind, not critical.

lyricnz’s picture

Thanks for the update. Kindof surprised nobody else on D7 noticed it...

mlncn’s picture

mlncn’s picture

Status: Needs review » Needs work

The last submitted patch, field_ui_add_existing_js-684310-9.patch, failed testing.

lyricnz’s picture

Version: 7.x-dev » 7.0-beta3

This bug still happens in beta 3.

lyricnz’s picture

Priority: Normal » Major

Bumping to "major" because UI is broken

webchick’s picture

Priority: Major » Normal

I agree this sounds annoying, but it's certainly not "major".

lyricnz’s picture

Version: 7.0-beta3 » 7.x-dev
yched’s picture

Status: Needs work » Needs review
StatusFileSize
new3.52 KB

Reroll of #9. Tested manually, works.

Steps to reproduce :
- On a default install, go to admin/structure/types/manage/page/fields ('Manage fields' for 'Page' node type)
- The 'Add existing field' row shows two potential fields to add : field_image, field_tags (defined for 'article' but not for 'page')
- when you select one of those, the 'Label' input should get populated with the Label of the existing instance.

JS behavior only, not bot-testable.

yched’s picture

beloved bot, can I haz test ?

bleen’s picture

subscribing

greenmother’s picture

This yched's patch works fine. How about to commit it in D7?

yched’s picture

Status: Needs review » Needs work

The last submitted patch, field_add_existing_prepopulate_label-684310-21.patch, failed testing.

greenmother’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, field_add_existing_prepopulate_label-684310-21.patch, failed testing.

ksenzee’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs work » Needs review
StatusFileSize
new3.44 KB

With the patch in #21 I was seeing two ' - Select an existing field - ' options: one being added to the $existing_field_options array, and one being added as the #empty_option. I removed the one from the $existing_field_options array and rerolled the patch for git and coremageddon. It seems to work fine. I hope the bot agrees.

yched’s picture

True, thanks for the reroll ! Now we need someone to RTBC...

lyricnz’s picture

Can confirm that bug still present in D8, and that #28 fixes it. Pedant: shouldn't we use '…' or '…' or t('...') rather than '...'?

Niklas Fiekas’s picture

Status: Needs review » Needs work

Maybe we should only update the label automatically, when the user hasn't manually entered something.

Other than that:

  • $existing_field_options is renamed. Maybe rather leave it as it is or rename the function that creates it, too.
  • The list of fields should still be sorted.
yched’s picture

Status: Needs work » Needs review
StatusFileSize
new4.92 KB

Updated patch:
- Re-adds the sorting.
- Removes the custom '...' ellipsis when truncating the strings and uses the one built in truncate_utf8()
- Only overwrites the "Label" input if it didn't receive manual edits (or if it's back to empty)

I'd rather keep the function name.

Niklas Fiekas’s picture

Status: Needs review » Needs work

Applies, works, looks awesome. Presumably passes the tests. Thank you :)

Minor point: Maybe val(...) instead of attr('value', ...)?

yched’s picture

Status: Needs work » Needs review
StatusFileSize
new4.9 KB

The rest of core is more consistent on val() vs attr('value'), so yeah.

Niklas Fiekas’s picture

Status: Needs review » Reviewed & tested by the community

Alright. Thanks.

lyricnz’s picture

Yay, works for me.

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: +Needs backport to D7

Looks like this has had plenty of manual testing, so committed/pushed to 8.x.

Doesn't this also need a backport?

Niklas Fiekas’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new4.86 KB

Working backport with just the filenames changed attached.

elc’s picture

Status: Needs review » Reviewed & tested by the community

Applies cleanly to current 7.x HEAD and functionally identical to D8 version which has been committed.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Oh man! This bug is really annoying. So happy to see a fix!

Committed and pushed to 7.x. Thanks! :)

Status: Fixed » Closed (fixed)
Issue tags: -Needs backport to D7

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