So I'm not actually sure about adding extra validation to the Form content
type.  I would start by looking at the default form page processor,
https://bitbucket.org/stephenmcd/mezzanine/src/ea1095020def16365c418dd3a7541635d38a2916/mezzanine/forms/page_processors.py?at=default#cl-26
.

One problem you may run into is that I think that processor will always
run, afaik there isn't a way to unregister a particular processor.


On Tue, Mar 4, 2014 at 10:33 AM, Danny flack <flackatt...@gmail.com> wrote:

> Hey Josh,
>
> Thanks for that.
>
> I believe I have a grasp on validating a custom form and returning it in
> the page's context, but what would be the strategy when you've created a
> page that has the "Form" content model, where you dynamically define all
> the form fields in Mezzanine's admin?  Is it possible to add validation to
> those fields?
>
> I've attached a screenshot where the form fields were added.
>
> I may be going about this all wrong, but I just want to verify.
>
> Thanks
>
> On Tuesday, March 4, 2014 9:45:52 AM UTC-8, Josh Cartmell wrote:
>
>> Hey Danny,
>>
>> Check out the example at https://mezzanine.jupo.org/
>> docs/content-architecture.html#page-processors, I think it will get you
>> started down the right path and shows how to handle validation in a
>> processor.
>>
>>
>> On Tue, Mar 4, 2014 at 9:37 AM, Danny flack <flack...@gmail.com> wrote:
>>
>>> Is it possible to validate a form in a page processor?
>>>
>>> I know you're able to override the associated form by something like:
>>>
>>> *@processor_for('rsvp')*
>>> *def rsvp_form(request, page):  *
>>>
>>> *    form = RsvpForm()  #  a custom form i created to override the
>>> page's form *
>>> *    return {"form": form}*
>>>
>>> But how would you go about intercepting and adding custom validation to
>>> the default page's form?
>>>
>>> For instance, I am trying to do something like:
>>>
>>> *@processor_for('rsvp')*
>>> *def rsvp_form(request, page):  *
>>>
>>> *    form = page.getAssociatedForm()  #  fabricated method to get the
>>> Page's form instance *
>>> *    form.addError('Some Error')  #  add custom validation*
>>> *    return {"form": form}*
>>>
>>>
>>> Am I going down the wrong path?  Is there another way to go about this?
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Mezzanine Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to mezzanine-use...@googlegroups.com.
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Mezzanine Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mezzanine-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to