Repositioning of Language field fails. It can not be placed after the body field once it has been placed above it.

Steps to reproduce:

1. git pull
2. drush si
3. drush en translation language
4. Login as admin and using admin/config/regional/language, add a language.
5. Using admin/structure/types/manage/article under language settings select Show language selector, Enable translation and then Save Content Type.
5. Edit Article. Select Show language selector, Enable translation, Save Content Type
6. View node/add/article and notice that the Language field comes right after Image. (Screen shot)
Screen Shot 2013-02-09 at 10.57.39.png
7. Using admin/structure/types/manage/article/fields, move Language after Title. (Screen shot)
Screen Shot 2013-02-09 at 11.00.10.png
8. View node/add/article and notice that the Language field comes after Title. (Screen shot)
Screen Shot 2013-02-09 at 11.04.32.png
9. Using admin/structure/types/manage/article/fields, move Language after Body. (Screen shot)
Screen Shot 2013-02-09 at 11.05.08.png
10. View node/add/article and notice that the Language field DOES NOT come after Title. (Screen shot)
Screen Shot 2013-02-09 at 11.06.57.png

Files: 
CommentFileSizeAuthor
#14 1912992-14.patch3.9 KBamateescu
PASSED: [[SimpleTest]]: [MySQL] 59,932 pass(es).
[ View ]
#11 1912992-11.patch3.92 KBswentel
PASSED: [[SimpleTest]]: [MySQL] 59,439 pass(es).
[ View ]
#11 interdiff.txt778 bytesswentel
#9 1912992-9.patch3.16 KBswentel
FAILED: [[SimpleTest]]: [MySQL] 59,037 pass(es), 1 fail(s), and 0 exception(s).
[ View ]
#9 interdiff.txt773 bytesswentel
#7 1912992-7.patch3.41 KBswentel
FAILED: [[SimpleTest]]: [MySQL] 59,034 pass(es), 1 fail(s), and 0 exception(s).
[ View ]
#7 interdiff.txt2.54 KBswentel
#5 1912992-5.patch898 bytesswentel
FAILED: [[SimpleTest]]: [MySQL] 59,429 pass(es), 7 fail(s), and 0 exception(s).
[ View ]
Screen Shot 2013-02-09 at 11.06.57.png42.01 KBmitron
Screen Shot 2013-02-09 at 11.05.08.png47.42 KBmitron
Screen Shot 2013-02-09 at 11.04.32.png39.92 KBmitron
Screen Shot 2013-02-09 at 11.00.10.png56.04 KBmitron
Screen Shot 2013-02-09 at 10.57.39.png57.39 KBmitron

Comments

Issue summary:View changes

Updated issue summary.

Title:Language Field get "Stuck" after TitleLanguage Field gets "Stuck" after Title

Assigned:Unassigned» beretta627

Assigned:beretta627» Unassigned

So the issue here appears to be with the way the language field information is stored. The two naming conventions that look to be in dispute are language and langcode. I'm willing to bet by correcting the naming conventions of the machine name this issue will be solved.

In the cache_field table the language field weight is being stored successfully in the extra field bundle field_info:bundle_extra:node:article. However, when the language select field is rendered on the node form in node/add/article, it's named langcode.

I traced the issue back a ways through the field.module, and isolated the problem to what is returned from field_info_extra_fields() in _field_extra_fields_pre_render(). $extra_fields is populated incorrectly with the name 'language,' while $elements contains the name 'langcode.' This discrepancy wiIl prevent $elements['langcode'] from being updated correctly. I added a simple conditional below to demonstrate the issue:

<?php
// in field.module, line 764
function _field_extra_fields_pre_render($elements) {
 
$entity_type = $elements['#entity_type'];
 
$bundle = $elements['#bundle'];
 
$extra_fields = field_info_extra_fields($entity_type, $bundle, 'form');
  foreach (
$extra_fields as $name => $settings) {
    if (isset(
$elements[$name])) {
     
$elements[$name]['#weight'] = $settings['weight'];
    }
   
// simple conditional demonstration to set the weight correctly
   
if ($name == 'language') {
     
$elements['langcode']['#weight'] = $settings['weight'];
    }
  }
  return
$elements;
}
?>

With that conditional added, the weight is correctly rendered on the node edit form.

I'm not entirely familiar enough with the larger scope of why the language module naming conventions are what they are, so I'll let someone else work through this a bit more. Hope this information helps however.

Component:language system» field system
Issue tags:+D8MI, +Field API

Confirmed this is still an issue.

This is probably more a field api problem then language, so changing the component.

Status:Active» Needs review
StatusFileSize
new898 bytes
FAILED: [[SimpleTest]]: [MySQL] 59,429 pass(es), 7 fail(s), and 0 exception(s).
[ View ]

This fixes it

Status:Needs review» Needs work

The last submitted patch, 1912992-5.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new2.54 KB
new3.41 KB
FAILED: [[SimpleTest]]: [MySQL] 59,034 pass(es), 1 fail(s), and 0 exception(s).
[ View ]

fixing tests

Status:Needs review» Needs work

The last submitted patch, 1912992-7.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new773 bytes
new3.16 KB
FAILED: [[SimpleTest]]: [MySQL] 59,037 pass(es), 1 fail(s), and 0 exception(s).
[ View ]

Status:Needs review» Needs work

The last submitted patch, 1912992-9.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new778 bytes
new3.92 KB
PASSED: [[SimpleTest]]: [MySQL] 59,439 pass(es).
[ View ]

Djeez

Status:Needs review» Reviewed & tested by the community

This is so confusing! I had to dig a bit in EntityFormController and the fix is correct. RTBC hoping that the tests will pass this time.

Status:Reviewed & tested by the community» Needs work
Issue tags:+Needs reroll

Patch no longer applies.

Status:Needs work» Reviewed & tested by the community
Issue tags:-Needs reroll
StatusFileSize
new3.9 KB
PASSED: [[SimpleTest]]: [MySQL] 59,932 pass(es).
[ View ]

Rerolled.

Status:Reviewed & tested by the community» Fixed

Wow, what a fantastic bug report! :) Glad the fix was so easy.

Committed and pushed to 8.x. Thanks!

Issue summary:View changes

Updated issue summary.

Status:Fixed» Closed (fixed)

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