Search code examples
formsplonedexterity

Adding a confirmation form before the add form of a content type


One of our customers wants to add a terms of service page that has to be shown every time a user adds some specific content type, before the add form.

Any suggestions on how to implement this?


Solution

  • If it's a Dexterity content type, you can do this:

    Create a custom form with your terms of service. In the form's button handler, redirect to the add form:

    self.request.response.redirect(self.context.absolute_url() + '/++add++name.of.content.type')
    

    Now in your type's factory info in portal_types, set the add_view_expr like this:

    <property name="add_view_expr">string:${folder_url}/@@terms-of-service</property>
    

    so it goes to the custom TOS form when you click the type in the factory menu, instead of directly to the add form.

    (Note: a downside of this approach is that if the user enters the URL of the add form directly, they can bypass the TOS form.)