[support] creating forums with drupal_execute
Stefan Borchert
stefan at borchert.cc
Mon Mar 26 11:34:51 UTC 2007
Hi.
I'm trying to import forum data from fud to drupal.
Creating the containers is done very easy but if I want to create the
forums within these containers it fails:
<code>
$containers = _fud_get_categories();
foreach ($containers as $data) {
$values['name'] = utf8_encode($data->name);
{...}
// this works:
drupal_execute('forum_form_container', $values);
// get new tid from database...
$tid = {...}
$forums = _fud_get_forums($data->id);
foreach ($forums as $forum) {
$values['name'] = utf8_encode($forum->name);
{...}
$values['parent'][0] = array($tid => $tid);
drupal_execute('forum_form_forum', $values);
}
}
</code>
The second drupal_execute runs into an error: "An illegal choice has
been detected. ..." (form.inc: function _form_validate(); #555).
I know why this error appears but I don't know how to solve it: if you
create a forum (admin/content/forum/add/forum) the list of parents is
build by using taxonomy_get_tree().
After creating a forum container with drupal_execute the tree isn't
updated (static variable in taxonomy_get_tree()) so the new container
isn't available in the parent list and the "illegal choice" error is thrown.
Is there a way how to update the tree? Or clear the static variable
(static $children) in taxonomy_get_tree()?
Or is it possible to set $form['#DANGEROUS_SKIP_CHECK'] with
drupal_execute() (if set the options wont be checked)?
I tried but couldn't get it work.
(The other option is to create the containers first, create a mapping
array (old id from fud => new tid in drupal) and then create the forums.
But this would be the last option.)
greetings,
Stefan
More information about the support
mailing list