Fwd: Re: [development] #just_before_validation ?

Dave Cohen drupal at dave-cohen.com
Sun May 21 01:15:05 UTC 2006


Sent this from the wrong address originally...

----------  Forwarded Message  ----------

Subject: Re: [development] #just_before_validation ?
Date: Saturday 20 May 2006 14:30
To: development at drupal.org

If you are defining the node type:

in hook_form(), no need to set $form['title'].

In yournodetype_node_form_submit($form_id, $form_values), do something like:

$form_values['title'] = 'whatever you want';
return node_form_submit($form_id, $form_values);


If you're not defining the node type, you can probably remove the title in
hook_form_alter, and do the same thing in the _submit().

-Dave

On Saturday 20 May 2006 01:16, Bèr Kessels wrote:
> Hi,
>
> I am looking for the following: I want to generate the title of a node from
> content in that node.
>
> Hence I need to hook into the node submission on several places.
>
> First: hook_form_alter, to make the title field hidden
> Then just *before* validation to capture the node content and fill a title.
> So that all possible validation hooks can still run, but that the title has
> a value.
>
> Any idea what kind of hook, or #callback I should be looking at?
>
> #validate is not a good option, since I think it is important to run all
> the normal validations on that title field. But maybe the trick is to set
> that #validate, and inside that callback function fill the title value and
> then call all the validation hooks from there? I am personally not a fan of
> using validation to cahnge values. Validation is for.... validation.
>
> Also important is, that this needs a POST, because I have to grab info from
> that POSTed node.
>
> Bèr

-------------------------------------------------------


More information about the development mailing list