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

Allow null group assignment for users #867

Closed
lcharette opened this issue Mar 28, 2018 · 5 comments

Comments

@lcharette
Copy link
Member

commented Mar 28, 2018

This will probably require a db migration to allow nullable value. The UI need to be allow for a "no group" option.

(Ref #843)

@lcharette lcharette added this to the 4.2.0 milestone Mar 28, 2018

@lcharette lcharette modified the milestones: 4.2.0, 4.3.0 Oct 13, 2018

@lcharette lcharette modified the milestones: 4.3.0, 4.4.0 Jan 14, 2019

@amosfolz

This comment has been minimized.

Copy link
Contributor

commented Apr 8, 2019

Since this will require another DB migration I thought it might be good to include it in the same release as #957 since that will require one as well. If there are no problems I will start working on it.

@amosfolz

This comment has been minimized.

Copy link
Contributor

commented Apr 9, 2019

I am running into some problems trying to figure out the best way to handle this. I am running into foreign key constraints from the relationships added here https://github.com/userfrosting/UserFrosting/blob/master/app/sprinkles/account/src/Database/Migrations/v420/AddingForeignKeys.php#L44

Even if we make the users.group_id column nullable, we will not be able to save a value unless it also exists in the groups.id
image

@lcharette

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2019

That's because the group_id is 0 while it should be null.

See : https://stackoverflow.com/a/15082906/445757

@amosfolz

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2019

That's because the group_id is 0 while it should be null.

See : https://stackoverflow.com/a/15082906/445757

Can we use value="0" on the form, then in the controller do a check? Something like this right before the update is made:

       if ($data['group_id'] == 0) {
           $data['group_id'] = null;
       }

Otherwise validation fails if group_id is not a integer.

amosfolz added a commit to amosfolz/UserFrosting that referenced this issue May 11, 2019

amosfolz added a commit to amosfolz/UserFrosting that referenced this issue Jun 15, 2019

amosfolz added a commit to amosfolz/UserFrosting that referenced this issue Jun 19, 2019

@lcharette lcharette modified the milestones: 4.4.0, 4.3.0 Jun 25, 2019

amosfolz added a commit to amosfolz/UserFrosting that referenced this issue Jul 11, 2019

amosfolz added a commit to amosfolz/UserFrosting that referenced this issue Jul 11, 2019

amosfolz added a commit to amosfolz/UserFrosting that referenced this issue Jul 11, 2019

lcharette added a commit that referenced this issue Jul 12, 2019

Merge pull request #964 from amosfolz/issue-#867
Allow null group assignment for users (Issue #867)
@amosfolz

This comment has been minimized.

Copy link
Contributor

commented Jul 18, 2019

Was addressed in #964.

@lcharette lcharette closed this Jul 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.