
I'm a web developer based in Manchester, England. I also design websites. I generally favour open-source technologies such as PHP, MySQL and JQuery, and I have extensive experience using Drupal.
As has been commented elsewhere, when you’re programmatically inserting data the most reliable way of doing so is often to simulate form submission – that way, any validation rules are applied and other modules have a chance to intercept the submission to do what they need to with the data.
This was achieved using the function drupal_execute:
$form_state = array();
$form_state['values'] = array();
$form_state['values']['field1'] = $value1;
$form_state['values']['field2'] = $value2;
drupal_execute('your_form_id', $form_state);
However, drupal_execute has gone altogether from Drupal 7.
Instead, you need simply replace any call to drupal_execute with the new function drupal_form_submit (see the documentation). Otherwise, everything (from the point of view of your syntax) remains the same.
Don't forget to use form_get_errors() to ensure that the form has validated.

I'm a web developer based in Manchester, England. I also design websites. I generally favour open-source technologies such as PHP, MySQL and JQuery, and I have extensive experience using Drupal.
Read more...Lukas,
Thanks so much for posting this, could you possibly help a newbie out and show...
Read more...Hello,
I'm using bootstrap with Less .
I'm trying to get this package to work with...
Read more...Thanks for the add-on! I'd love to use it but when installing I was told it was incompatible...
Add your comment