[Zope3-Users] label customisation

1 view
Skip to first unread message

Simon Elbaz

unread,
Jul 13, 2013, 9:12:49 PM7/13/13
to zope3-users
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

unread,
Jul 13, 2013, 10:16:07 PM7/13/13
to zope3...@zope.org, elbaz...@gmail.com
On 7/13/13 8:12 PM, Simon Elbaz wrote:
> 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


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

Simon Elbaz

unread,
Jul 19, 2013, 9:06:39 AM7/19/13
to zope3-users
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
Reply all
Reply to author
Forward
0 new messages