English 中文(简体)
1. 采用宽度表和田径
原标题:Using invariant with Dexterity form and fieldsets

我有一个内容类型,来自插头。 Schema;它在四个领域拥有十几个领域。 我试图创建一条从两个不同领域看田的zope.interface.invariant。

从追查行为来看,它像惯犯一样,一度被召到each fieldset,但不是整个形式。

我知道,我可以提供我自己的手稿,进行我所需要的一切检查,但是,与明确界定的老百姓相比,我感到ky。 虽然明显的解决办法是将相关领域移至同一领域,但目前的设置反映了终端用户合乎逻辑的布局。

Is there an existing hook where I could perform validation on multiple fields across fieldsets?

最佳回答

答案似乎是没有的:z3c.form.group.Group.extractData callsz3c.form.form.BaseForm.extractData,每组/外地一次,这一呼吁已经包括不间断的验证。

您不登记自己的handler,也可超越extractData:

from plone.directives import form, dexterity
from z3c.form.interfaces import ActionExecutionError,WidgetActionExecutionError
# ...

class EditForm(dexterity.EditForm):
  grok.context(IMyEvent)

  def extractData(self, setErrors=True):
    data, errors = super(EditForm, self).extractData(setErrors)

    if not None in(data[ start ], data[ end ]):
      if data[ end ] < data[ start ]:
        raise WidgetActionExecutionError( end , Invalid(_(u"End date should not lie before the start date.")))
      if data[ end ] - data[ start ] > datetime.timedelta(days=7):
        raise WidgetActionExecutionError( end , Invalid(_(u"Duration of convention should be shorter than seven (7) days.")))

    return data, errors

请注意,这一类别源自减产。 EditForm, 包括Dexterity的违约处理器,而不是形式。 SchemaForm。

<代码>WidgetActionExecutionError并不可靠地运作。 在一些领域,它产生了一个关键错误。

问题回答

暂无回答




相关问题
Bind Button.IsEnabled to custom validation with XAML?

I am sorry I didn t know how to title my question any better, you name it if you got a good 1. I have an entity Contact. this person has navigation properties: Address, Phones (A collection of Phone)....

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

Wpf Combobox Limit to List

We are using Wpf Combobox to allow the user to do the following things: 1) select items by typing in the first few characters 2) auto complete the entry by filtering the list 3) suggesting the first ...

Rails 101 | validates_currency?

I ve searched high and low, but I could not find a solution, to what I think seems like a very common task. In a form I want to have a text input that accepts currency strings (i.e. $1,000,000 or ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签