- Issue created by @steven jones
- Merge request !10378Issue #3490435: States not being processed correctly on item form items. β (Open) created by steven jones
- π¬π§United Kingdom steven jones
Adding more words to the title of the issue.
Okay, so the tests failed as expected.
I wonder what the correct solution is here?I'm going to push the change to go back to the sub-optimal check for the type of element fix, as that would actually work correctly, though not optimally.
Then maybe we need some further discussion about how to resolve this. Do we need a new property on form elements:
'#states_attributes_target_key'
that gives the name of the attribute to push the states attributes on to?
Core can set this on item and password_confirm elements to change the target, and anything that wants to do this in contrib can do this too. - π¬π§United Kingdom steven jones
Unassigning myself and setting to needs work, since we need to decide what to do here, but we do have an improved test and sub-optimal fix in the MR
I have hit the same problem, although in my case the #type is 'container'. My code worked correctly when I applied patch #2700667-104: Notice: Undefined index: #type in Drupal\Core\Form\FormHelper::processStates() β , but as of D10.3.8, that patch no longer applies, and my code no longer works (the #states I've specified are ignored). When I apply the update in MR !10378, then my code works correctly again (fields are hidden or visible as they are supposed to be). So, MR !10378 looks good to me, although I haven't checked to see if it causes anything else to break.
- Issue was unassigned.
- Status changed to Needs work
about 2 months ago 3:05pm 19 February 2025 - πΊπΈUnited States bkosborne New Jersey, USA
This bit me as well. I agree the logic introduced in the original code that introduced the regression is not correct.
- πΊπΈUnited States bkosborne New Jersey, USA
This patch works for me to resolve the issue. I know it's not an ideal fix, but this fixes the regression and I think it should be committed to address that so people don't keep hunting around for what caused it.
I don't understand why someone would create a form type 'item' and set
#markup
to an empty string and set#input
to TRUE. In what scenario does that make sense? I think most people using 'item' elements are in fact adding markup. - π¬π§United Kingdom catch
Would be nice to get a form API maintainer review on this issue (shouldn't stop another framework manager committing it if they want to, but I'm not sure I want to without a second opinion on whether there's another option here).
- π³πΏNew Zealand quietone
Simplify title. No need to refer to the other issue in the commit message. The [regression] informs the reader there is an older issue involved.
Per #6, was there also a regression for
'#type' => 'container'
that is fixed here? In which case, should there be a test for that as well?- πΊπΈUnited States tim.plunkett Philadelphia
This should include test coverage for `container`