Why doesnt the 'rich text editor have a 'required' option?
Hello @peter.b,
In Retool, the Rich Text Editor doesn’t have a built-in "required" option like other form fields. To add validation, use custom logic for example, check if the content is empty before submitting the form (like mention in this community forum : Rich text editor missing basic functionality - #3 by Jack_T).
Use a transformer or a JavaScript query to validate:
// Custom validation query
const plainText = richTextEditor1.value.replace(/<[^>]*>?/gm, '').trim();
if (!plainText) {
utils.showNotification({ title: "Error", description: "Rich text is required.", type: "error" });
return false;
}
return true;
- Add a Text Component to Show an Error Message :
- Find the "Hidden" toggle in the right-hand panel.
- Paste this code:
{{ !!richTextEditor1.value.replace(/<[^>]*>?/gm, '').trim() }}
-
Execute the JavaScript query within the Rich Text Editor’s event handlers.
-
Here is a sample screen recording for reference.
Hi, Yes we know how to do that.
My question for Retool was why doesn't it have this as standard?
Thanks
Pete
Hi @peter.b,
Apologies for the inconvenience. I just created a feature request for this and tagged it onto a larger project our UI team is working on for a version 2 of the component.
As to why this feature is missing, my guess is that the first version was created with speed to release in mind. And now that there has been significant traction in use of the component and requests for additional functionality to improve the component, it has been gathering steam for a major upgrade with version 2.
Once again, I wish it had shipped all these features with version 1 but I can check with the team on where version 2 sits on our roadmap and let you know any updates I hear from our UI team and will continue to advocate for these feature requests to be prioritized!