moacode / craft-fab-permissions

Restrict access to fields and tabs for particular user groups across your Craft elements.
Other
16 stars 9 forks source link

Front end form validation issues #17

Closed tom-byrom closed 4 years ago

tom-byrom commented 4 years ago

Hi Josh, My edit user front end forms won't validate when there is a required field associated with another user group even if it is not shown in the form.

So for instance I have two user groups, people and companies.

People has a required field of 'Job Title'. But when I try and save the front end edit profile form for a Company it won't validate as it says it requires 'Job Title' field to be set. Even though it's not displayed in the form?

That specific field is only valid for People and have set the permissions correctly.

Anyway around this? Because it seems like if I edit the company profile from the CP when logged in as a company it works but on the front end it doesnt. I will only have front end forms eventually no access to CP.

Thanks

moacode commented 4 years ago

Hey Tom,

Thanks for reporting this issue! To help me replicate, could you please give me a little more information about how you're updating the user profiles? Are you using a method similar to this: https://docs.craftcms.com/v3/dev/examples/user-profile-form.html or do you have a custom route/model that's handling the validation and saving?

If it's using the Craft users/save-user action I'll whip up an example and do some investigation to get this resolved for you.

tom-byrom commented 4 years ago

@thejoshsmith thanks for the reply! Yes I'm using their example as a base form and just adding custom fields as per their example so I'm using the users/save-user action.

In my form - I have a simple if statement to show a field or not depending on the user group. Likely I'll have two different forms eventually but still can't see this being an issue currently.

Let me know how you get on!

Thanks

moacode commented 4 years ago

Hey @tom-byrom, I've just pushed release 1.4.0 which should resolve this for you.

It took of bit of consideration, but now permissions are applied to front end POST requests (previously the plugin didn't do anything on front end requests). This now means that when a user submits profile information, the "Job Title" won't be validated or stored for company users.

I'll close this issue for now, but feel free to reopen if it's not working for you!

tom-byrom commented 4 years ago

@thejoshsmith awesome thanks mate! Appreciate the update and all seems to be working - will let you know if I run into anything else.