Block setting for form elements

A lot of my snippets use {error:;block=yes} to ensure required fields are filled, which requires multiple if statements to do the checks.

{formtext:name=textbox1}
{if:textbox1=""}{error: text1 required;block=yes}{endif}
{formtext:name=textbox2}
{if:textbox2=""}{error: text2 required;block=yes}{endif}

A single check with one if statement doesn't offer the visual element the first way provides the user, where the error disappears once conditions are met, making it less intuitive.

{formtext:name=textbox1}{error: required}
{formtext:name=textbox2}{error: required}
{if:textbox2="" OR textbox1=""}{error: Please ensure all textboxes are filled out;block=yes}{endif}

Would be nice if it were offered as a setting for all form elements.

something like:

{formtext:name=textbox;block={if:name =""}{error:name requred}{endif}}

Hi,

Thanks for sharing this idea. I think it sounds cool!

Just so I understand, you would like text fields to have a setting that makes it a required field? So, instead of adding an if statement for each text field, you could just toggle a setting and that would make it a required field?

Please let me know if that's what you had in mind.

1 Like

Having a toggle for text fields, dropdown menus and paragraph fields would definitely be convenient, but having the "Required" icon/text disappear once a condition is met would make it perfect!

Notice the "required" errors besides the textboxes in the second snippet of my original post are persistent, regardless if the textboxes are filled or not. If I have several "required" elements in a form and one of them were missed it would be hard to locate at a quick glance.

I understand. Having a 'required' setting that automatically does for you what the if statement + error command does would be useful.

In the meantime, using an if statement for each individual field like your first example might be the best solution.

Totally a wonderful idea!

1 Like