Hi, cliff,
Could you please explain me how to create custom edit form for archetype ? i
guess thats what you have done when you said customAddForm
Quoting Cliff Ford <[EMAIL PROTECTED]>:

To answer my own question, and for the benefit of anyone else who wants
to customise an addform:

Even though I have a class with a createAndAdd method I found that it
was necessary to include the content_factory directive in the addform
configuration as well as the class and template directives.

I copied the createAndAdd method from ../zope/app/form/browser/add.py
and added this line: self.gotoURL = str(content.__name__) after content
= self.add(content), having previously set gotoURL='' as a class
variable. I have a nextURL method:

def nextURL(self):
     return '../%s' % self.gotoURL

And lo and behold on submission of the add form I get the browser view
of the added object. Magic!

I am doing this customisation because I want to collect essential Dublin
Core data with data for the content object, rather than rely on users
filling in the metadata form later.

Cliff


Cliff Ford wrote:
I have a custom addform that works fine with a standard configuration. However, on submission it redirects to the contents view of its container and I want it to redirect somewhere else, such as the new object's edit or metadata views. All I really need is a nextURL configuration directive, mentioned in mailings some time ago, but I don't think that has been implemented.

I have created a class with a __call__ method that returns the custom form template, and a nextURL() method. In the configuration file I have replaced the content_factory directive with the class directive.

With the custom form and class, the form displays and field validation still works, but with valid fields I get an object creation error:

File "/usr/local/Zope3/src/zope/app/form/browser/add.py", line 71, in create
    return self._factory(*args, **kw)
TypeError: 'NoneType' object is not callable

I have looked at the add.py module and am none the wiser. I guess I have neglected to set something somewhere, may be context related. Can anyone enlighten me? The custom class has almost nothing in it (see below) so I am surprised it gets as far as it does. [I have also searched the archives and read both recent Zope3 books but can't find an answer.]

Cliff

Custom class:

from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile

class PageAddFormD:
    """This class reads the form data and creates a custom Page"""

    template = ViewPageTemplateFile('pageaddformd.pt')

    def __call__(self):
        return self.template()

    def getInterfaces(self):
        """ Don't know if I need this here """
        return implementedBy(GlgPage)

    def nextURL(self):
        """ return the next place to go """
        # have not got this far yet
        return '../'
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users






_______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to