Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groups added to the 'Other groups' field are lost on submit #149

Merged
merged 16 commits into from
Feb 15, 2016

Conversation

pfrenssen
Copy link
Collaborator

I noticed that the 'Other Groups' field is not working at all. There are two bugs there:

  • If the 'Group Audience' field is left empty, a target reference with ID NULL is added to the list.
  • The wrong element in the $form array is inspected when looking for the field.

A third bug is preventing the tests from completing:

  • The config schema for the complex widget is missing.

This has been split off from the larger work of converting the OG Complex widget tests in #140, so that this important fix can go through without waiting for that mammoth task to complete. I have also cherry-picked the two commits from #147 that allow us to run functional tests on Travis.

@pfrenssen
Copy link
Collaborator Author

Above test fails correctly because it detects that it is impossible to add groups through the 'Other groups' field.

@pfrenssen
Copy link
Collaborator Author

This fixes it and should turn the test green. Note that there is still a bug left: it now hardcodes the field name, so it only works for one group audience field. This will be tackled when I get to OgComplexWidgetTest::testMultipleFields().


// Get the groups from the other groups widget.
foreach ($form['other_groups'] as $key => $value) {
// @todo Don't hardcode 'og_group_ref' - there can be multiple fields.
foreach ($form['og_group_ref']['other_groups'] as $key => $value) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->fieldDefinition->getName() 👍

@pfrenssen
Copy link
Collaborator Author

Thanks @damiankloip! Much obliged :)

// @see https://github.com/amitaibu/og/issues/144
/** @var EntityFormDisplayInterface $form_display */
$form_display = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load('node.post.default');
$widget = $form_display->getComponent('og_group_ref');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as indicated in the issue, this one troubles me a bit (even if it's an intermediate step). I'd be happy to see the next step to make this work for all audience fields

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's do #144 first, it should be pretty trivial.

@pfrenssen
Copy link
Collaborator Author

The tests started failing after merging in the master branch. It was due to the OgStandardReferenceItem that was added in #128 - it was using the wrong validator, causing the following error when saving a node that references a group:

Error: Call to undefined method Drupal\Core\TypedData\Plugin\DataType\IntegerData::isEmpty() in Drupal\Core\Entity\Plugin\Validation\Constraint\ValidReferenceConstraintValidator->validate() (line 78 of core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ValidReferenceConstraintValidator.php).

This test was actually detecting that already :)

@amitaibu, I have fixed the visibility of the group audience field in #153, this is merged into this issue. The fix to make it work with all audience fields has also been applied. Is there anything else that needs to be done here?

@pfrenssen
Copy link
Collaborator Author

I created a separate issue for the fatal error when saving group content, so that it is more easily discoverable if someone runs into this problem: #154.

@pfrenssen pfrenssen added the bug label Feb 12, 2016
@RoySegall
Copy link
Collaborator

@amitaibu Checked it and the other groups widget works very good.

amitaibu added a commit that referenced this pull request Feb 15, 2016
Groups added to the 'Other groups' field are lost on submit
@amitaibu amitaibu merged commit ecc36af into 8.x-1.x Feb 15, 2016
@amitaibu amitaibu deleted the other-groups-no-references branch February 15, 2016 11:12
@amitaibu
Copy link
Owner

Merged, thanks!

amitaibu added a commit that referenced this pull request Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants