-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: dirty state isn't saved when serialize a model #15571
Labels
Comments
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
5 tasks
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
BeMySlaveDarlin
pushed a commit
to BeMySlaveDarlin/cphalcon
that referenced
this issue
Nov 9, 2021
Resolved in #15780 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Describe the bug
When you have a form with an existing entity (state is persisted) and then you save the form in a session. When you retrieve the form on the next request (or more future requests), you get the form with it's entity. Every data is restored, except the dirty state.
This is because the serialize() method in Model class, only saves the data and not the state.
When unserializing the entity, it returns to it's default dirty state, transient.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
You should expect that the dirty state isn't changed.
Details
Additional context
I found this out because I save my form to session and then restore it from session when submitted.
One of the entities has a validator Uniqueness validator. There is a check in which the entity is check on dirty state == 0.
So when submitted with the same value as in the database row, it failed on this validator. Because the state == 1 and so it doesn't leave out the row linked with the entity while validating.
I extended the serialize() method so it saves the dirty state. Maybe there is a reason behind this why state is not saved?
The text was updated successfully, but these errors were encountered: