I am trying to use this with a field on a Profile2 type.
I can take the same field with the exact same settings (same field base) and place it on content type and it works no problem
Here is what happens.
- The profile2 edit form is shown
- Click "Add Items"
- Select items in the view.
- Close the window.
- All the content appears correct
- Save the Profile
- After Profile is saved no content appears selected.
When attached the same field the to a content type it everything is the same except that the values are saved. I have also tried with an Entityform Type and it works fine.
I also tried switching the field on Profile2 to checkboxes widget(not using this module at all). The values save correctly.
I then switched back to the widget provided by this module. At that point when I load the edit profile form it shows the correct content checked but no matter I do, uncheck all the selected content or add more when I save the profile it keeps whatever values where set before I switched back to this widget.
I have all this with 7.x-2.x-dev and 7.x-2.x-alpha2
Thanks for any help
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | entityreference_view_widget-fix_single_form_parent-2207761-4.patch | 770 bytes | tedbow |
Comments
Comment #1
bojanz commentedProfile2 embeds the fields one level below the main form.
This might be relevant, since the ids and form structures are different than expected.
Comment #2
tedbow@bojanz thanks for the quick reply.
Yes I think that is the problem.
Don't know the solution but here is where the problem is
$input is set to null because drupal_array_get_nested_value can't loop through the $element['#parents'] array to find the nested elements. After the first element in the parents array the 2nd isn't set(at least in my example).
Comment #3
tedbowFYI I also tried the dev version of Profile2 and that didn't help.
Comment #4
tedbowOk I found the problem!
It is in entityreference_view_widget_field_widget_form.
If count($form['#parents']) == 1 then
implode('][', $parents)will return an empty string
and parents_path will be something like this:
first_parent[][field_name]Of course [] is a problem.
So this problem will not happen if
$form['#parents']is empty or ifcount($form['#parents']) > 1Probably why it is only showing up with Profile2
So I am attaching patch that changes it to
This fixes it for me with Profile2 but also still works for nodes. Basically covers the $form['#parents'] only having 1 element.
Comment #5
tedbowComment #7
jsacksick commentedThanks for your contribution tedbow! Committed (e1781da)
Comment #8
tedbowjsacksick, no problem glad I could help out this awesome module!