[development] form_builder and the $form['#type'] .'_value' callback.

Darrel O'Pry dopry at thing.net
Wed Feb 7 02:11:22 UTC 2007

I started asking chx about this in IRC last night. I've been working on
a few custom form elements for handling files. I need a chance to save
files locally before #validate is reached. Chx, suggested #after_build,
but I am having issue with my #after_build being called from my element
prototype(the default #type values returned from hook_element).

While looking through form.inc and trying to figure out why my
#after_build function wasn't being called when triggering a submit
button on the page I notice there is a large select in form_builder for
some default element types, to assign their values from edit/_POST.

The _value callback is for defining default values according to chx, and
is a rarely used function. I thought it might be a neat idea to move
this hard coded select out of form_builder and use the _value  callback
to assign the #value in form_builder and set the #needs_validation if a
value is return from the _value callback. Otherwise use the
#default_value defined in the form or the element prototype.

I think the behavior would make it easier to build form_elements that
don't return a value (type=file ad unchecked type=checkbox are the only
ones I know of)  and need to generate their value from contextual data.


More information about the development mailing list