Re: get validated single field values?, was: Patch for labelfield "validation"

Clemens Klein-Robbenhaar <crobbenhaar-S0/[email protected]> Sat, 23 Apr 2005 01:08:02 +0200
Newsgroups gmane.comp.web.zope.formulator.devel
Message-ID <[email protected]>
Hi Reinout,

> I spend the day improving ploneformmailer (which wednesday tripped the
> now-fixed bug) and got the idea that there's something that's not done
> properly.
> 
> a) What I'd expect: ploneformmailer calls
> form.validate_entire_form_or_so and afterwards iterates over the
> fields and gets a value out of them.
> 
> b) What ploneformmailer does: it doesn't call the entire-form
> validator, but iterates over the fields and uses field.validate() to
> get the value out of the field...
> 
> I added the call to validate the entire form in one go (also doing
> away with the validation of label fields): no problem. But I couldn't
> really find a good function to call to get the value out of a field.
> Just a list of selected options for a multicheckboxfield, for
> instance. field.validate() seemed like the best option after all.

I am not sure what the problem is about.
"form.validate(request)" returns a dictionary of all validated
values; the ids of the fields are the keys.
  Alternatively one can use "validate_to_request" and the results
are stored in the requst therafter. So what problem getting the values?

  Looking shortly at the code I found a couple of things it should not do,
like accessing "field_..." parameters in the request ... seems to be a real plone
product <wink />

Aftgr grepping for "valiate" I found something like this:

  value = context.validate(context.REQUEST)

where context is the field.

  Instead one should be able to say:

  value = REQUEST.other[context.id]

as the value are already stored in the request via "validate_to_request" earlier.

(This does no apply if an validation error occured, but in that case a plain
call to "field.validate()" would be no good either.)

Cheers,
Clemens