Mailing List Archive

Required fields / minimum length
Hi,

Is it possible to make a field required and and set a minimum length?

I've created an Image element type, and added an Alt field (for alt
text). I would like to ensure that the user is forced to enter a value
in this field. Setting a value for Minimum Occurrence ensures that the
field is displayed in the GUI, but that field can still be left blank.

I can possibly throw an error from the template, but that seems a little
messy. How do others solve this?


Regards,

Mike
Re: Required fields / minimum length [ In reply to ]
Hi Mike,

I'm afraid throwing the error from the template is how it's done.

You can pre-populate the field by typing a value in it in the element
type manager. Maybe something like "REPLACE ME WITH REAL ALT TEXT!"



Hope this helps,

Bret


On Sun, 2011-05-15 at 18:14 +0100, Mike Raynham wrote:
> Hi,
>
> Is it possible to make a field required and and set a minimum length?
>
> I've created an Image element type, and added an Alt field (for alt
> text). I would like to ensure that the user is forced to enter a value
> in this field. Setting a value for Minimum Occurrence ensures that the
> field is displayed in the GUI, but that field can still be left blank.
>
> I can possibly throw an error from the template, but that seems a little
> messy. How do others solve this?
>
>
> Regards,
>
> Mike
>

--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret@pectopah.com
www.pectopah.com
Re: Required fields / minimum length [ In reply to ]
Hi Bret,

After posting my question, I thought about it some more, and realised
that this brings up the whole area of user input validation. Required
fields are just the start of what can be a big and complex task, so I
guess leaving it out of the GUI is a sensible idea.


Thanks for your help.


Regards,

Mike


On 15/05/11 20:50, Bret Dawson wrote:
> Hi Mike,
>
> I'm afraid throwing the error from the template is how it's done.
>
> You can pre-populate the field by typing a value in it in the element
> type manager. Maybe something like "REPLACE ME WITH REAL ALT TEXT!"
>
>
>
> Hope this helps,
>
> Bret
Re: Required fields / minimum length [ In reply to ]
On 2011-05-15, at 4:00 PM, Mike Raynham wrote:

> Required fields are just the start of what can be a big and complex task, so I guess leaving it out of the GUI is a sensible idea.

That said, I have wanted to propose the ability to specify input validation on field-level elements for a long time (as well as help text for the field). I think it makes total sense to validate before a save or a preview.

--
Phillip Smith
http://phillipadsmith.com
http://twitter.com/phillipadsmith
http://linkedin.com/in/phillipadsmith
Re: Required fields / minimum length [ In reply to ]
On May 17, 2011, at 6:08 AM, Phillip Smith wrote:

>> Required fields are just the start of what can be a big and complex task, so I guess leaving it out of the GUI is a sensible idea.
>
> That said, I have wanted to propose the ability to specify input validation on field-level elements for a long time (as well as help text for the field). I think it makes total sense to validate before a save or a preview.

+1

I'm sure we could add quite a few simple validators, and make it pluggable.

David