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

David Glick (Plone) david.glick at plone.org
Wed Dec 5 18:59:52 UTC 2012


I think you can also say min_length=1 ... but the error message in case 
the list is too short might be cryptic, IIRC.
David

On 12/5/12 10:57 AM, Christian Ledermann wrote:
> 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.
>>
>> }<(((*>
>
>



More information about the Product-Developers mailing list