Postponed (maintainer needs more info)
Project:
Drupal core
Version:
main
Component:
forms system
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
29 Jan 2017 at 13:51 UTC
Updated:
22 Jan 2026 at 16:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
_Archy_ commentedAdded an implementation for this. Don't know for sure, but I didn't see any way that the FormState knows about the form, so I added as a parameter the form. But it would be nice if that parameter didn't exist. If anyone has an idea. Maybe implement a way for a form state to know about the forms default values?
Tests will be added when this approach is confirmed good.
Comment #3
shadcn commented$this->getCompleteForm();will get you the form.See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21Fo...
Comment #5
_Archy_ commented@arshadcn for that method to return the form, it must be set first with setCompleteForm() on the form state. It isn't always set. In the context I was testing this new method it wasn't set, so to use that I would have to set it before calling isDirty().
I don't really understand all this fails for the patch. It only introduces a new method. Also checked that I made it for the right branch (8.3.x). Maybe someone can explain?
Comment #6
xjmComment #7
tim.plunkettWhen was this? If it wasn't set, the form was not finished building, so it would be too early to check for all #default_value elements anyway, since all #process and hook_form_alters will not have run yet.
The error is:
Class Drupal\Core\Form\SubformState contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Drupal\Core\Form\FormStateInterface::isDirty)Nit: should be the same line
This can be an infinitely nested array. Checking the form at the top level will not work here.
What is a use case for this?
Comment #8
_Archy_ commentedThanks for looking into this. I will think of other ways when I'll have time.
Till then I'll link the issue from which this idea came. That will explain a use case and will give you the context in which the for wasn't set on the form-state.
Comment #11
_Archy_ commentedDid some work for this. Refactored they way the checking works. Addressed comments from #7. Created tests, but only unit ones. Do we need functional ones?
Comment #12
_Archy_ commentedThis method of checking is not the best performance wise as it is linearly taking all elements of the form and comparing the values till it gets one that has different value. It works well if we check for all the values of the form, but when we want just a subset of fields to check it still traverses the whole form. This could be improved if there is a way of converting #parents to #array_parents, but I am not sure that is possible.
Comment #24
smustgrave commentedThank you for sharing your idea for improving Drupal.
We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!