[drupal-devel] Rewriting use of forms in Drupal

Gerhard Killesreiter killesreiter at physik.uni-freiburg.de
Fri Jun 3 11:43:45 UTC 2005



On Fri, 3 Jun 2005, Moshe Weitzman wrote:

> > a) Easier value checking.
> >
> > In _validate we would then build the form a second time to check that
> > all the fields still have the type and value they are supposed to have.
> >
> > foreach ($form_elements as $name => $value) {
> >   switch($value['type']) {
> >     case 'textfield':
> >       if (!is_string($edit['value'])) {

That should have been $edit[$value['name']].

> >         form_set_error(...);
> >       }
> >       if (is_empty($edit['value']) && $value['required']) {
> >         form_set_error(...);
> >       }
> >       break;
> >     case 'textarea':
> >      ....
> >   }
> > }
> >
>
> Who does the validation? Core, or the module?

This kind of basic validation should be in core.

> How would that work for a form outside of the node forms? ...

Just the same.

> The direction sounds good so far.

Thanks.

Cheers,
	Gerhard




More information about the drupal-devel mailing list