Posted by angeliti on May 14, 2008 at 7:24am
Hello everyone!
I'm having problems when trying to add tags to the story/page creation form using simpletest.
I have a vocabulary which uses FREE TAGGING, and I want create a new page with the tag "cat". The vid of the vocabulary is stored in the class attribute 'free_tagging_voc'. What I've been trying to do is the following:
$edit = array();
$edit['title'] = $this->randomName(10);
$edit['body'] = '';
$edit['taxonomy']['tags'][$this->free_tagging_voc] = 'cat';
$this->drupalPostRequest('node/add/page', $edit, 'Submit');However, this results in the following error message when running the test:
[browser] Setting taxonomy="Array" at [/Applications/MAMP/htdocs/drupal-5.7/sites/all/modules/simpletest/drupal_test_case.php line 111]Anybody can please tell me what's the right way of doing what I'm trying to do?
Thanks!
Ángel.-

Comments
It looks like you're trying
It looks like you're trying to access the form array directly instead of what the browser sees. $edit needs to contain the form element as it's rendered in html. So a freetagging vocabulary produces html like
<input id="edit-taxonomy-tags-1" class="form-text form-autocomplete" type="text" value="" size="60" name="taxonomy[tags][1]" maxlength="255" autocomplete="OFF"/>Meaning that line would look more like this:
$edit["taxonomy[tags][$vid]"] = 'cat';You were right
That was exactly the problem.
Thank you very much!! =)
Ángel.-