[Product-Developers] Dexterity: make a list field required

Christian Ledermann christian.ledermann at gmail.com
Wed Dec 5 18:57:52 UTC 2012


OK figured out a workaround:

def isnotempty(value):
    return bool(value)


   layers = schema.List(
            title=_(u"Layers"),
            description=_(u"WMS Layers"),
            required=True,
            constraint=isnotempty,
            value_type=schema.Choice(
                 source=layers_vocab,
                 required=True,
                 ),
    )

On Wed, Dec 5, 2012 at 9:50 PM, Christian Ledermann
<christian.ledermann at gmail.com> wrote:
> I try to make a list filed required for a dexterity type:
>
>
>     layers = schema.List(
>             title=_(u"Layers"),
>             description=_(u"WMS Layers"),
>             required=True,
>             value_type=schema.Choice(
>                  source=layers_vocab,
>                  required=True,
>                  ),
>
> but when I save the edit form it does not complain wether
> the list field is filled or not
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Nairobi - Kenya
> Mobile : +254 702978914
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>



-- 
Best Regards,

Christian Ledermann

Nairobi - Kenya
Mobile : +254 702978914

<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>


More information about the Product-Developers mailing list