pods-framework / pods-gravity-forms

Integration with Gravity Forms plugin for WordPress (https://pods.io/gravityforms/)
https://wordpress.org/plugins/pods-gravity-forms/
GNU General Public License v2.0
62 stars 10 forks source link

Multi-Select relationship field not being updated #45

Closed tomodea42 closed 6 years ago

tomodea42 commented 8 years ago

We have a problem with the use of the Pods Gravity Forms Add-On.

When we have a multi-select field which represents a relationship to another Pod, only the first item in the multi-select list gets accepted.

Software Versions We are using WordPress Version: 4.4.2 with these plugins: • Gravity Forms: 1.9.17.5. • Pods - Custom Content Types and Fields: 2.6.1. • Pods Alternative Cache: 1.0. • Pods Frontier Auto Template: 1.2.1. • Pods Gravity Forms Add-On: 1.0.

The Business Need The aim is to enable the users to create a Project and invite people to Volunteer for that project. We therefore have a many-to-many relationship between Projects and Volunteers. When we display a Project, we want to include in the display a list of the volunteers that have signed up for that project. Similarly, when we display a Volunteer, we want to include in the display a list of the projects the volunteer has signed up for.

Pods Definitions We have defined 2 Pods Custom Post Types:

  1. Special Projects.
  2. Special Projects Volunteers. The Special Projects Pod includes a field called special_projects_volunteers which is defined as a Bi-directional Field which links to the Special Projects Volunteers Pod. This is defined as a Multiple Select Checkboxes field. The Special Projects Volunteer Pod includes a field called special_projects which is defined as a Bi-directional Field which links to the Special Projects Pod. This is defined as a Multiple Select Checkboxes field. The Special Projects Pod has a custom taxonomy called Special Projects Category and the Volunteers Pod has a custom taxonomy called Job Role. Each project can have only one category and each Volunteer can have only one job role.

Using Pods We can successfully create new instances of Projects and Volunteers and establish many-to-many relationships between them via the WordPress backend. We can successfully display projects and volunteers and follow the links from a project to a volunteer or from a volunteer to a project. The displays are presented using Pod templates. We want to use Gravity Forms to provide a user-friendly front-end to enable authorised users to submit a new Project or to sign up as a Volunteer.

Gravity Forms Definitions There are 2 Gravity Forms forms:

  1. Submit a Special Project Form.
  2. Sign Up as a Special Projects Volunteer Form. The Submit a Special Project Form includes a field which is defined as a Checkboxes field with Allow field to be populated dynamically and a parameter name of special_projects_volunteers. This is the name of the relationship field defined within the Special Projects Pod. Populate Related Items has been selected and a Pods Feed has been defined. The Sign Up as a Special Projects Volunteer Form includes a field is defined as a Checkboxes field with Allow field to be populated dynamically and a parameter name of special_projects. This is the name of the relationship field defined within the Special Projects Volunteers Pod. Populate Related Items has been selected and a Pods Feed has been defined.

Use of Pods Gravity Forms Add-On We are using the Pods Gravity Forms Add-On to handle the mapping between each of the Gravity Forms form fields to the appropriate Pods field. There are 2 Pods Feeds defined:

  1. Submit a Special Project Form has a Pods feed called Special Projects Feed.
  2. Sign Up as a Special Projects Volunteer Form has a Pods feed called Special Projects Volunteers Feed. This is working very well and we can even present the user with a selection list for the custom taxonomy, i.e. the Project Category or the Job Role. The user can select any one of the categories or job roles as required and that data is stored in the Pod. The list of related Pods items is also presented. However, when the user makes a selection from that list, only the first item on the list is stored in the Pod – the other items are ignored. If the user makes a selection other than the first item on the list, nothing is stored.

Here is an example:

  1. We have created 2 projects: Special Project 1 and Special Project 2.
  2. We have created 2 volunteers: Volunteer 1 and Volunteer 2.
  3. We then submit a new project for Special Project 3 using a Gravity Forms form.
  4. The form shows Volunteer 1 and Volunteer 2 as being available to be assigned to the project.
  5. If we select both volunteers, only Volunteer 1 is stored.
  6. If we submit a new project for Special Project 4 and select Volunteer 2, that selection is ignored and no volunteer is stored. If we edit a project using the WordPress backend, we can select any number of volunteers and the updates will be stored correctly.

I've attached 2 TXT files: a JSON export of the Pods configuration and a JSON export of the Gravity Forms configuration. gravityforms-export-2016-03-19.json.txt pods-export-2016-03-19.json.txt

tomodea42 commented 8 years ago

I'd be most grateful if someone could have a look at this problem and let us know if something can be done to address it. Thanks, Tom O'Dea

zepartner commented 7 years ago

I'm having a similar problem, however, my issue is that I can't get the bi-directional field to save when populated from the predefined hidden field that has a predefined value of {user:user_login}. Jim tried to assist me with this tonight but it was out of support hours so we couldn't get to the bottom of it.

The field is generating perfectly within the gravity form on the front end and the post is saving the other fields, but it doesn't save the user-ID as the user within the bi-directional field.

Any help would be great.

Thanks

sc0ttkclark commented 7 years ago

Please try the latest 1.4 I'm working on: https://github.com/pods-framework/pods-gravity-forms/archive/feature/skc-fixes.zip

winnersmedia commented 6 years ago

I believe I have the same issue. I have a multi-step form and it is not remembering the check boxes chosen when I push next and then previous. I've tried using the suggested code posted by sc0ttkclark but this hasn't fixed the issue for me. I can provide a URL for this if required.

If this issue is not likely to get resolved soon could you update this thread so i can request a refund from gravity forms as it this is a requirement for me to be able to use the plugin.

sc0ttkclark commented 6 years ago

Ask Gravity Forms for access to their new beta add-on that is generalized for custom fields. It's not Pods specific and doesn't come with some of the things we have in our add-on, but it should be suitable and works great. It's not yet released, so you'd be using some sort of beta version of it, but it's high quality from the code I've seen and used.

I wouldn't request a refund for your Gravity Forms license, it's still a great solution and they deserve the money for their efforts plus support.

jimtrue commented 6 years ago

@winnersmedia It also sounds like you're experiencing a different issue than what is described in the bug above. This is about 'populating' existing records and the relationship fields not loading. Your issue sounds like the selections in the form aren't remembering their selections between sessions in a next and previous page form. That's a Gravity Forms bug and you should escalate to them since you have purchased the product.

jimtrue commented 6 years ago

@letmegreg Based on your question above:

I'm having a similar problem, however, my issue is that I can't get the bi-directional field to save when populated from the predefined hidden field that has a predefined value of {user:user_login}. Jim tried to assist me with this tonight but it was out of support hours so we couldn't get to the bottom of it.

The field is generating perfectly within the gravity form on the front end and the post is saving the other fields, but it doesn't save the user-ID as the user within the bi-directional field.

If you're connecting to a relationship through a hidden field, you'd use the Meta Tax {user:ID}, not {user:user_login} because the relationship to 'Users' is to the ID not the login.

winnersmedia commented 6 years ago

Hi, this is the response from gravity forms:

Hi Matt,

I'm afraid this is something the pods team will need to fix, they are only populating the field via the gform_pre_render filter, for the choice selection to remain when paging on a multi-page form they also need to populate the field via the gform_pre_validation filter.

jimtrue commented 6 years ago

Thanks for the update @winnersmedia. @sc0ttkclark Do you need this particular piece in it's own Issue since I don't think this and the original error report are related at all?

winnersmedia commented 6 years ago

Hi, is this now a new issue? Seems quite an important one. Is there a workaround?

sc0ttkclark commented 6 years ago

Try the latest 1.4 beta, I pushed a fix for the hook there:

https://github.com/pods-framework/pods-gravity-forms/archive/feature/skc-fixes.zip