[Grok-dev] How to create Cancel that doesn't validate form in grok.EditForm
Sebastian Ware
sebastian at urbantalk.se
Thu Dec 11 10:17:17 EST 2008
Thanks both! This worked like a charm. I added:
NoValidation = lambda *args, **kwargs: {}
and then imported it, allowing:
@grok.action('Cancel', validator=NoValidation)
I agree that it would be great to have something like "NoValidation"
available out of the box, I hope it makes it into the 1.0 so it is
included in sample code and tutorials.
Mvh Sebastian
11 dec 2008 kl. 14.59 skrev Leonardo Rochael Almeida:
> having to repeat "lambda *args, **kwargs: {}" kind of sucks. I usually
> define it to a constant in my apps, but I think it'd be nice if grok
> defined it as grok.FormNoValidation or somesuch.
>
> Cheers, Leo
>
> On Thu, Dec 11, 2008 at 11:56, Andreas Kaiser <kaiser at xo7.de> wrote:
>>
>> Sebastian Ware wrote:
>>
>>> In a grok.EditForm, how do I mark an action so it doesn't require
>>> validation of the form?
>>>
>>> I am thinking about the use case "cancel". I don't want to get error
>>> messages due to invalid input if I choose the "cancel" action.
>>
>> I don't know if it applies to grok.EditForm as well, but this is what
>> I've done with a grok.Form:
>>
>> @grok.action('Cancel', validator=lambda *args, **kwargs: {})
>> def cancel(self, **data):
>> self.redirect(self.application_url())
>>
>>
>> HTH,
>>
>> Andreas
>> _______________________________________________
>> Grok-dev mailing list
>> Grok-dev at zope.org
>> http://mail.zope.org/mailman/listinfo/grok-dev
>>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
More information about the Grok-dev
mailing list