The media_mover module contains this function, which builds a form and pre-populates default values:
/* step 1 */ $form = media_mover_api_configuration_base_form($configuration);
It also contains this function, which submits the form:
/* step 2 */ function media_mover_api_add_config_form_submit($form, &$form_state)
I would like to programmatically generate the form (step 1), and then programmatically submit the form (step 2).
Step 1 is not a problem; I am able to generate
$form. For step 2, I need
$form, is there a way to programmatically generate its corresponding
$form_state? I am using Drupal 6.
This is a more detailed explanation of what I am trying to accomplish.
I am able to programmatically fill out and submit a particular form by laboriously setting all the field values in
$form_state['values'], and then calling
However, the process would be much simpler if I could instead use this function, which converts a
$configuration object into
$form, and does all the heavy lifting:
$form = media_mover_api_configuration_base_form($configuration);
This function enters a default value into each form field.
The only missing step, then, is to copy all these default field values from
$form_state['values']. I am wondering whether there is a function to do this. Or is there a way to loop through all the fields in
$form and extract the field-name and default value?