Problem/Motivation
When we have two shs fields with the same name - one attached to the node and another attached to a paragraph we get the same default value in shs field in the paragraph as the one in the node.
Steps to reproduce
1. Create a shs field and attache it to a node type.
2. Create a paragraph type and attach to it a shs field with the same name as the one attached to the node.
3. Create a paragraph field in the node from the newly created paragraph type.
Proposed resolution
the code in src/Plugin/Field/FieldWidget/OptionsShsWidget.php:
$field_name = $this->fieldDefinition->getName();
$default_value = $element['#default_value'] ?: NULL;
$user_input = $form_state->getUserInput();
if (isset($user_input[$field_name])) {
$default_value = $user_input[$field_name];
}
needs to be adapted so element parents are taken into account
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3173133-default-value-bug.patch | 1.36 KB | ventzie |
| #2 | 3173133-default-value-bug.patch | 1.32 KB | ventzie |
Comments
Comment #2
ventzie commentedComment #3
ventzie commentedComment #5
stborchertSorry, I forgot to commit your changes before making changes related to another issue. So i "faked" a commit to add credits :)