On 6/7/06, <b class="gmail_sendername">Moshe Weitzman</b> <<a href="mailto:weitzman@tejasa.com">weitzman@tejasa.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> - how does one validate a node programmatically *correctly*?<br>> - what is the point of the "node_validate()" function and the hooks if<br>> it doesn't actually *validate* the node at all? At least rename it to
<br>> "node_noop()" so things are clear.<br>> - really, why have "node_validate()" at all? Does anyone do anything<br>> usefull in it?<br><br>good question.<br><br>unfortunately, 4.7 is a bit of an intermediate solution which makes this
<br>hard. the conceptual way to do is is to programtically "submit" the story<br>form. In 4.7, this amounts to populating the proper $_POST variables like<br>'type' and 'title' and so on and then building the node form by calling the
<br>right functions and then calling drupal_get_form(). the node form is the<br>most complex of all our forms so i'm not sure this works right.</blockquote><div><br>OK. This is more or less the path I'm following: getting the node-form array passing it the $node object. This will set the #default_value everywhere. Then I copy the #default_value values into #value and set #need_validation. Then I do a drupal_form_validate().
<br><br>Problem here is: form_set_error() keeps a static variable of the errors on the form. So if you want to import *two* nodes, the errors of the first run will still be present in the second run with no way of clearing them.
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">form api 2.0 will be focused on making things like this easy again.</blockquote><div>
<br>I'm not critizing form api 1.0. I think it works great in most cases. But not in mine :-(<br>Seperating data (with validation / submit) and the actual form seems like the way forward.<br><br> Robrecht</div></div>