On Sep 15, 5:53 pm, Martin Aspeli <[EMAIL PROTECTED]> wrote:
> Daniel Holth wrote:
> > Another plone.z3cform problem -- I am having trouble finding the
> > minimum template that will "just work" if I setup
>
> > index = ViewTemplateForm('something.pt')
>
> You shouldn't need to specify a template to have it "just work"; the
> default layout template should work (at least if you have
> plone.app.z3cform installed, which provides the Plone default look and
> feel template).http://paste.plone.org/23853 is my code. It is working now but I did not know how to do everything I wanted to do. It does "just work", but when I try to set my FormWrapper's index = to the things I've tried (all variations on ViewPageTemplateFile('a- template-included-in-plone.z3cform.pt') the form does not render, complaining about missing attributes in my FormWrapper. Reading farther in plone.z3cform's source code, it looks like I might just create an adapter ZopeTwoFormTemplateFactory(path, form=IMyFormWrapper), have my form wrapper implement that interface, and register the adapter in zcml, and then I will have a customizable template that "just works". Not sure. > > I've tried the templates from plone.z3cform to no avail. All I really > > want to do is to add a class to the <body> tag, which I can do > > (messily?) in FormWrapper.__call__ by setting template.id = "some- > > string". > > Look at the standard templates then. They have macros you can re-use. I repeatedly feel like I am missing some great tutorial on how to ask the component registry which component is registered for what. I did eventually find that layout.pt is the default template for these forms but I did not notice that when stepping through and inspecting layout.py's FormWrapper.__call__ "template" variable in the debugger. > > The other things I have not yet figured out include how to replace the > > default "Yes/No" for a Bool() field with a checkbox widget, and how to > > have widgets that provide instructions between fields without asking > > for any input. Any advice? > > There's a widget for this in z3c.form, I think; you just need to set a > custom widgetFactory. For more detailed control over text and layout, > you'll need a custom template. That really should work like z3c.form so > look at its docs. I wasn't sure where to manipulate a manager = field.Fields(ISomething) ... just in the top level of my .py file defining the form's interface? Or where to manipulate a manager = field.FieldWidgets(personForm, request, srichter), which are different kinds of managers? In the z3c.form documentation, the user calls .render() from the prompt, but in plone.z3cform the framework renders the form, so it was not clear to me how to transfer that documentation to my work. For me, the z3c.form documentation would benefit greatly from a "here is the complete source code to do x" listing, after running through the doctest snippet / commmentary sequences. I had trouble understanding how the parts are supposed to combine together to create a working whole. I do really appreciate being able to throw a field specific error after the "validation" stage as in some other Plone form frameworks, because in my application I would otherwise have to do two expensive geolocation lookups to complain about an unknown postal code, or I would have to cache the expensive lookup in the validation phase and somehow connect that to the results phase. That's why I am using z3c.form now. Thanks! Daniel Holth _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
