0

LinguaPlone 使用 MultiSelect 小部件来选择多种语言。像 InOut 小部件甚至 MultiCheckBox 小部件这样的东西将是一个更好的用户界面,因为很难从一长串列表中看到所有选定的语言。

我尝试使用以下方法覆盖 FormFields:

form_fields['available_languages'].custom_widget = MultiCheckBoxWidget

正如 zope.formlib 文档中所建议的那样,但我得到了如下回溯:

Traceback (innermost last):
  Module ZPublisher.Publish, line 128, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module zope.formlib.form, line 795, in __call__
  Module five.formlib.formbase, line 50, in update
  Module zope.formlib.form, line 758, in update
  Module plone.fieldsets.form, line 30, in setUpWidgets
  Module zope.formlib.form, line 402, in setUpEditWidgets
  Module zope.formlib.form, line 334, in _createWidget
TypeError: __init__() takes exactly 4 arguments (3 given)

如何覆盖默认小部件?

4

1 回答 1

0

你需要的是:

from zope.formlib.widgets import OrderedMultiSelectWidget
from Products.LinguaPlone.browser.controlpanel import LanguageControlPanel

def MyMultiCheckBoxWidget(field, request):
    return OrderedMultiSelectWidget(field, field.value_type.vocabulary, request)


LanguageControlPanel.form_fields["available_languages"].custom_widget = MyMultiCheckBoxWidget
于 2013-06-15T07:12:16.577 回答