I need to programmatically set many forums.
It basically works, but I have a problem with the parent setting:

$values['name'] = 'test 11 Container name';
$values['description'] = 'This is my new forum';
$values['parent'] = '22';
$values['weight'] = '1';
drupal_execute('forum_form_container', $values);

When the parent < 10, it works as expected, but if parent >= 10, only the first digit of the parent is taken into account!
I.e., if parent = 15, the parent will be set as 1, and if parent = 22, it will be 2.

Comments

beginner’s picture

If in this function:
function forum_form_submit($form_id, $form_values) {
I do:
print_r($form_values);
the substitution has already taken place.

cburschka’s picture

Version: x.y.z » 5.x-dev
Status: Active » Closed (works as designed)

This is not a bug. The parent field is represented by a select field in the form and therefore becomes an array:

  ["parent"]=>
  array(1) {
    [0]=>
    string(1) "1"
  }

The code has to pass an array as well:

$values['name'] = 'test 11 Container name';
$values['description'] = 'This is my new forum';
$values['parent'] = array('22');
$values['weight'] = '1';
drupal_execute('forum_form_container', $values);
beginner’s picture

Oh my! Thanks.
I'll test that.

RobRoy’s picture

See my post at http://drupal.org/node/106015 about why this doesn't work with nested taxonomy. Or maybe I'm missing something. That patch has turned into a bit more and I didn't have time to push it before the freeze.

beginner’s picture

Status: Closed (works as designed) » Closed (duplicate)

I haven't had time to test what Arancaytar suggested, yet.
RobRoy seem to imply that this issue has been duplicated in the other one.