[Zope3-Users] Customisation of addform

Roger Ineichen dev at projekt01.ch
Sun Nov 28 12:22:13 EST 2004


Florian Lindner wrote:
> Sent: Sunday, November 28, 2004 5:30 PM
> To: dev at projekt01.ch; zope3-users at zope.org
> Subject: Re: [Zope3-Users] Customisation of addform
> 
> Roger Ineichen schrieb:
> > Hi Florian
> 
> Hi!
> You sent your email to zope3-users-request at zope.org. It never reached 
> the list.

I don't know why, but why, but all mails are rejected.
I fix this later, Thanks

> >>-----Original Message-----
> >>From: zope3-users-bounces at zope.org 
> >>[mailto:zope3-users-bounces at zope.org] On Behalf Of Florian Lindner
> >>Sent: Sunday, November 28, 2004 9:48 AM
> >>To: zope3-users at zope.org
> >>Subject: [Zope3-Users] Customisation of addform
> >>
> >>Hello,
> >>I've a standard addform which looks like that (the HTML 
> >>source which was 
> >>filled in the body slot of the page macro. (shortened)
> >>
> >>   <div>
> >>   <div>
> >>     <form 
> >>action="http://localhost:8080/++skin++centershock/eventfolder/
> >>+/AddCSEvent.html%3D"
> >>           method="post" enctype="multipart/form-data">
> >>       <div>
> >>         <h3>Add CSEvent</h3>
> >>
> >>       <div class="row">
> >>           <div class="label">
> >>             <label for="field.name" title="Short name">Name</label>
> >>           </div>
> >>           <div class="field"><input class="textType" 
> id="field.name" 
> >>name="field.name" size="20" type="text" value=""  /></div>
> >>           </div>
> >>
> >>
> >>         <div class="separator"></div>
> > 
> > 
> > Don't forget the widget lookup, otherwise you can't use 
> this zpt as a 
> > template attribute in the <addform> directive.
> > 
> > <div metal:use-macro="context/@@form_macros/widget_rows" />
> 
> Sorry, can you explain this a bit more detailed?
> You mean, the addform directive is using this
> <div metal:use-macro="context/@@form_macros/widget_rows" />
> for every row?

Yes each row get rendered with this macro.
This macro is responsible for the layout part for widgets.


> So I can define a macro form_macros in the context file. By default 
> context == skin_macros but I can change it by changing ZCML 
> addform->template. This macro is repeated for each field and 
> the field 
> is filled in the widget_rows macro?
> Is that right?

Yes

> Is there a piece of code to see how the addform is being 
> generated? So I can see which macros and skin it uses.

See zope.app.rotterdam.standardmacros.py

> 
> > You also can use a own macro an repeat the widgets there. 
> > This way you can cutomize the look and feel of the repaeated 
> > area of your widgets.
> 
> By defining a slot widget_rows in the skin_macro file or the 
> file name 
> given in addform->template?

I don't understand that.

You can define macros (page template) with the page directive.
Let's say 'my_layout_macros'
 
In this page template you can defin a macro. Let's say 'my_widgets'.

In the addform template use and repeat this macro like.

<div metal:use-macro="context/@@my_layout_macros/my_widgets" />

That's all you have to do.

In the standardmacros.py in the rotterdam package is just a hook
over a mapping which supports alias names for macros.
That's not important for this solution. It's nice but not the simpliest 
way.

> 
> 
> > 
> > 
> >>         <div class="separator"></div>
> >>
> >>       </div>
> >>       <br /><br />
> >>       <div class="row">
> >>         <div class="controls"><hr />
> >>
> >>           <input type="submit" value="Refresh" />
> >>           <input type="submit" value="Add"
> >>                  name="UPDATE_SUBMIT" />
> >>
> >>         </div>
> >>       </div>
> >>
> >>       <div class="separator"></div>
> >>     </form>
> >>   </div>
> >>
> >>   </div>
> >>
> >>
> >>What possibilities do I have to modify this form?
> >>
> >>1) Modifiy the page macro, use CSS.
> >>2) Using an alternate template (ZCML: template)
> >>, maybe using ZCML: class_ for custom widgets.
> > 
> > 
> > The class attribute in the <addform> directive is used for 
> > to use another view class for the template.
> > 
> > You can replace template and class in the <addform>.
> 
> I was meaning class_ (with a underscore). But I just see that 
> there is 
> no class without underscore. Is there a special meaning in 
> the underscore?
> > 
> >>3) Changing ZCML: title, menu, label, fields
> >>4) ...??
> > 
> > 
> > 5) Use widgets as a subdirective in <addform>
> >    for each field.
> > 
> > 6) Use another 'widget_rows' form macro
> 
> 6 is the same as described above, isn't it?
> 
> Thanks for telling me if my assumptions above are correct.
> 
> Best regards,
> 
> Florian


Regards
Roger
> 
> 



More information about the Zope3-users mailing list