Re: Deexterity: Validation of multiselection Field with input from Vocabulary
espen <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.user |
|---|---|
| Message-ID | <[email protected]> |
( I dont really know if this is a good idea9, but Could you • set the field to be required • Let one of the options be «Please choose» • Set «Please choose» as default • validate the field for not (contains) «please choose» Espen 1. mars 2015 kl. 20:01 skrev andreasma [via Plone] <ml-node+s293351n7573302h15-PKuAHvtXa09l57MIdRCFDg@public.gmane.org>: > Hello, > > I try to validate a Dexterity multiselection field that is created like this: > > category_choice = schema.List( > title=_(u"Choose your categories"), > value_type=schema.Choice(source=vocabCategories), > required=True, > ) > > > I tried to validate if this field is not empty. I wasn't successful by using @invariant with a function that raises an error message if data.category_choice is None. > > > @invariant > def noCategoryChoosen(data): > if data.category_choice is None: > raise MissingCategory(_(u"You must choose at least one category for your project")) > > > > class MissingCategory(Invalid): > __doc__ = _(u"You have not chosen a category for the project") > > > The test seemed to fail because the field has some value / data. > > I tried the same with a constraint for the schema.List field with the same result. > > Thanks for any hints in advance. > > Regards, > Andreas > -- > ## Developer LibreOffice > ## Freie Office-Suite für Linux, Mac, Windows > ## http://LibreOffice.org > ## Support the Document Foundation (http://documentfoundation.org) > ## Meine Seite: http://www.amantke.de > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for all > things parallel software development, from weekly thought leadership blogs to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > Plone-Users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/plone-users > > > If you reply to this email, your message will be added to the discussion below: > http://plone.293351.n2.nabble.com/Deexterity-Validation-of-multiselection-Field-with-input-from-Vocabulary-tp7573302.html > To start a new topic under General Questions, email ml-node+s293351n293352h65-PKuAHvtXa09l57MIdRCFDg@public.gmane.org > To unsubscribe from Plone, click here. > NAML -- View this message in context: http://plone.293351.n2.nabble.com/Deexterity-Validation-of-multiselection-Field-with-input-from-Vocabulary-tp7573302p7573304.html Sent from the General Questions mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Plone-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/plone-users