- Issue created by @lostcarpark
- 🇺🇸United States ultimike Florida, USA
All valid questions - especially the "trim units" field not being an integer 😱
A couple of thoughts:
- Let's tackle this one when/if 📌 "More link" formatter configuration UI improvements Fixed is committed.
- We should take a look at other core/contrib modules to see how/if they handle validation in formatter config.
-mike
- 🇮🇳India sanket.addweb
I resolved the issue by changing the field type from 'textfield' to 'number' and making the 'More text URL' field required when the 'Display More link?' checkbox is checked.
- 🇮🇪Ireland lostcarpark
@sanket.addweb, looks an interesting solution.
Changing the field to a number makes sense.
Making the "More text URL" required when "Display more link" is checked, but from a quick look, this is only implemented on the form generation. If the user checks "Display more link", the URL field will be shown, but will not be required until the form is submitted. The ideal would be to add a validate function to check if the field is populated, but it doesn't appear to be possible to add validation to a field formatter.
- 🇮🇪Ireland lostcarpark
One minor point, the
checkboxStatus
ortestcheckboxStatus
function in the above patches is only called from within the class, so I think it should be a protected member rather than a public one. - 🇮🇳India sanket.addweb
@lostcarpark, I have made the necessary changes by replacing the public function with a protected function. Additionally, I conducted research on the "validateSettingsForm()" method and applied the validate handler in the formatter's setting form. However, the current implementation is not functioning as expected. I will continue investigating to identify and resolve the issue.
- Status changed to Needs review
8 months ago 10:39am 25 April 2024 - Status changed to RTBC
7 months ago 9:51am 26 May 2024 - 🇮🇳India hasmimeraj
Applied patch #7 to smart_trim:^2.1 and manually tested with drupal 10.2.6. All looks good.
Since field settings are updated by ajax request. So error message are stored in session.
And when you finally save the changes then error message appear with successfully settings saved message.Btw this is expected behavior. So marking this for RTBC
- Status changed to Needs work
7 months ago 9:38am 29 May 2024 - 🇺🇸United States ultimike Florida, USA
@sanket.addweb - thanks for your efforts on this. Moving back to "Needs work" because we need to add at least one test for this. I would like to see a test that attempts to set the "Trim units" field to a non-integer and maybe also a test that covers the #required bit.
-mike