webbyfox
webbyfox

Reputation: 1079

Overriding Dexterity default view type

We have object which is let say xyz and its view is xyz_view which dexerity expect page template file. Is there any way to override default page type to controller page template rather?

So view should be xyz_view.cpt rather then xyz_view.pt ?

Regards,

Upvotes: 1

Views: 397

Answers (2)

Christoph Böhner
Christoph Böhner

Reputation: 421

Include a form that submits to itself inside your view template and use the 'update()' method to process the request and redirect on some condition:

class View(grok.View):
    grok.context(IMyType)
    grok.requires('zope2.View')

    def update():
        if 'form.button.Submit' in self.request:
        input_value = self.request.get('input_value', None)
        if input_value is not None:
            self.request.response.redirect(self.context.absolute_url() + "@@process-this")

See the five.grok manual instructions about simple views for more information

Upvotes: 1

SteveM
SteveM

Reputation: 6048

There is no realistic scenario for using controller page templates for dexterity forms. There is also no scenario that I can think of where it would be easier than using z3c.form.

Upvotes: 3

Related Questions