Discussion:
[Zope3-Users] label customisation
Simon Elbaz
2013-07-14 01:12:49 UTC
Permalink
Hi,

In the z3c.form.AddForm, zope.schema.List field is rendered with Add/Delete
buttons.

How to customize those labels ?

My code does not have any effect:
AddAction = button.StaticButtonActionAttribute(
u'Add Action', button=multi.MultiWidget.buttons['add'],
form=StepAddForm)

Thanks for your help
Simon Elbaz
Christopher Lozinski
2013-07-14 02:16:07 UTC
Permalink
Post by Simon Elbaz
Hi,
In the z3c.form.AddForm, zope.schema.List field is rendered with Add/Delete
buttons.
How to customize those labels ?
I will take a shot at this.

From
https://github.com/zopefoundation/z3c.form/blob/master/src/z3c/form/form.txt
lines 697 to 711

What you want to do is to create and register an adaptor to change the
form labels. Maybe that also applies to the button labels.

Next question, why does your code not work? Maybe we can figure that
out also. Let me ask you a few questions.

Let me make sure I understand you. You want to display a list, and add
or delete items that you select from the list.

What is the add button currently displaying? "Add" ? What do you want
it to display?

I suspect that you have written that section of code correctly, maybe
the problem is elsewhere in the code. If you provide more of the
code that would create a helpful and useful context.

If you could include an image of what your form looks like that that
makes it so much easier to then read the code.

Hope that helps. I see so few active Zope 3 developers, I try to help
those who are active.

What are you building?

I am clozinski on skype if you want to chat more about this problem.

Regards
Christpher Lozinski
zopache.com
Simon Elbaz
2013-07-19 13:06:39 UTC
Permalink
It's not the most elegant way but it does the job:

def updateWidgets(self):
super(StepAddForm, self).updateWidgets()
AddAction = button.StaticButtonActionAttribute(
u'Add Action',
button=self.widgets['o_action_list'].buttons['add'])
zope.component.provideAdapter(factory=AddAction, name='title')
super(StepAddForm, self).updateWidgets()


where o_action_list is the zope.schema.List field.

I have to call super(StepAddForm, self).updateWidgets() because
self.widgets is not avalaible before the call.

Regards,
Simon
Post by Simon Elbaz
Hi,
In the z3c.form.AddForm, zope.schema.List field is rendered with
Add/Delete buttons.
How to customize those labels ?
AddAction = button.StaticButtonActionAttribute(
u'Add Action', button=multi.MultiWidget.buttons['add'],
form=StepAddForm)
Thanks for your help
Simon Elbaz
Loading...