Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Steps to reproduce
1. fresh Drupal install
2. add a Name field to user account settings
3. add description to name field
4. visit /user/add or /user/*/edit & get WSOD
Log says
Fatal error:
Cannot use object of type Drupal\\name\\Plugin\\Field\\FieldWidget\\NameWidget as array in .../name.module on line 451
the problem code is
if (!$field || $field['cardinality'] != 1) {
$element['_description'] = array(
'#value' => '<div class="clearfix description">' . $element['#description'] . '</div>',
);
....
}
I don't understand what that if() block is doing, and removed it from my installation.
Comment | File | Size | Author |
---|---|---|---|
#21 | 2629910-21.patch | 1.6 KB | webflo |
| |||
#19 | interdiff-2629910-19.txt | 848 bytes | thenchev |
#19 | wsod_caused_by-2629910-19.patch | 1.42 KB | thenchev |
| |||
#16 | wsod_caused_by-2629910-16.patch | 605 bytes | thenchev |
| |||
#12 | wsod_caused_by-2629910-12.patch | 4.26 KB | thenchev |
|
Comments
Comment #2
John_B CreditAttribution: John_B commentedComment #3
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedA looked into this a just removing the cardinality check works for me. Tested it out with different cardinality settings. So wanted to make a test coverage too but then i got some schema errors:
[01-Apr-2016 20:21:17 Australia/Sydney] Uncaught PHP Exception Drupal\Core\Config\Schema\SchemaIncompleteException: "Schema errors for field.field.node.page.field_name_test with the following errors: field.field.node.page.field_name_test:default_value.0.title missing schema, field.field.node.page.field_name_test:default_value.0.given missing schema, field.field.node.page.field_name_test:default_value.0.middle missing schema, field.field.node.page.field_name_test:default_value.0.family missing schema, field.field.node.page.field_name_test:default_value.0.generational missing schema, field.field.node.page.field_name_test:default_value.0.credentials missing schema" at /var/www/html/d8/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php line 98
looks like a followup to me.
Comment #5
Alan D. CreditAttribution: Alan D. commentedWithout the check is the description repeated on every element? I think that was the reason for this check.
If not, all good, if so then (without doing any D8 programming yet) isn't $field simply an object, so $field->getCardinalityOrWhateverTheFunctionIsCalled() should work?
Comment #6
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedBy manual testing no duplicate without the check. So all fine :)
the obj is Drupal\name\Plugin\Field\FieldWidget\NameWidget i will have to see how to best get the cardinality.
Comment #7
Alan D. CreditAttribution: Alan D. commentedCool, but quick clean up maybe.
Late here, but thinking that with this change all we are left with is if the element has a description, render that afterwards if it is a Name Element (as opposed to a Field Widget).
Luckily this saves bridging into the field storage definition; actually a bit surprised you have to do something like this:
Comment #8
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedDone the cleanup, also improved test to check that the description is unique.
Still remains to check the schema errors. Maybe some idea?
Comment #10
Alan D. CreditAttribution: Alan D. commentedWebflo, any comments on that?
Comment #11
BerdirWell, simple enough, the value schema is missing :)
See field.value.string for example in core.data_types.schema.yml.
Comment #12
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedThanks for the help.
This should make the test pass and add all missing schema.
Comment #14
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedThanks!
Comment #15
John_B CreditAttribution: John_B commentedThanks indeed :-)
Comment #16
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedLooks like i missed some schema last time. Right now im getting some schema errors when I use a exported view. Really sorry I'm reopening this but its just a small fix i don't think we need to open a new issue.
Comment #17
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedLooks fine. This is related to #2691491: Add name field to the contact entity
Comment #18
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedPatch looks good, but the is no markup default setting in NameFormatter::defaultSettings. Can you fix the defaultSettings? Thanks!
Comment #19
thenchev CreditAttribution: thenchev at MD Systems GmbH commentedUpdated the NameFormatter::defaultSettings
Comment #20
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedRTBC.
Comment #21
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedMarkup is a checkbox, i think boolean fits better in this case.
Comment #22
webflo CreditAttribution: webflo at UEBERBIT GmbH commented