If $form->setHTMLID('xxxx') is used, serverside validation (javascript disabled) will send you back to an empty form without any messages if validation fails.
This applies to 3.2 at least. Unfortunately I haven't been able to find the cause yet
I鈥檝e also encountered this but haven鈥檛 investigated it. The workaround I鈥檓 using for now is to call $form->setupFormErrors() after calling $form->setHTMLID(). I assume we鈥檙e relying too much on IDs rather than form names for error messages
Ok, if that works, that's fine for now, thanks, even if it's now executed twice... :)
The form session content is namespaced to Form::FormName(), which is the HTML form name, overridden by getHTMLID.
It should probably use Form::getName() instead. However, one caveat is that a a potential reason for calling getHTMLID() is to ensure that multiple forms on a single page with the same getName() value have unique identifiers, which would be necessary to retain in session data namespacing.
That said, looking through core code, it appears as though that's _not_ the typical reason for using setHTMLID(), so maybe we could get away with changing to namespace on getName(). Otherwise we'd have to lazy-call restoreFormState(), which would be quite an invasive change.
PS: In SS4 setupFormErrors is now called restoreFormState().
@silverstripe/core-team views on namespacing the internal session data for forms by Form::getName() rather than Form::FormName()?
Is this affecting SS4? If not, I would suggest we close it as a "won't fix", especially considering there's a workaround.
Closing as SS 3 is in limited support. Will reopen if this is an issue in SS 4.
Most helpful comment
The form session content is namespaced to Form::FormName(), which is the HTML form name, overridden by getHTMLID.
It should probably use Form::getName() instead. However, one caveat is that a a potential reason for calling getHTMLID() is to ensure that multiple forms on a single page with the same getName() value have unique identifiers, which would be necessary to retain in session data namespacing.
That said, looking through core code, it appears as though that's _not_ the typical reason for using setHTMLID(), so maybe we could get away with changing to namespace on
getName(). Otherwise we'd have to lazy-call restoreFormState(), which would be quite an invasive change.PS: In SS4 setupFormErrors is now called
restoreFormState().@silverstripe/core-team views on namespacing the internal session data for forms by
Form::getName()rather thanForm::FormName()?