Hi,

I'm developing a module which uploads logfiles, moves them after upload and processes the logfiles.

I built the form in the drupal-way like so:

$form['#attributes'] = array('enctype' => "multipart/form-data");
$form['process_log'] = array(
	'#type' => 'fieldset',
	'#title' => t('Log Processing'),
	'#tree' => TRUE,
	'#collapsible' => TRUE,
	'#collapsed' => FALSE,
);
for($count_files = 1; $count_files <= count($hotel); $count_files++){
	$form['process_log']['logfile'.$count_files] = array(
		'#type' => 'file',
		'#name' => 'files[logfile'.$count_files.']',
		'#title' => t('Select Log for '.$hotel[$count_files-1]),
	);
}
$form['process_log']['submit'] = array(
	'#type' => 'submit',
	'#value' => t('Upload')
);

This generates a form with a variable amount of file fields. It all works just fine, however in the way I call the form it always displays the form after submit. I would much rather display text after upload which files were processed. The code I use for the menu-link and the code to load the form are like this:

$items['hotels/hotels_process/process_multiple_files'] = array(
	'parent' => 'hotels_process',
	'title' => 'Multiple Files',
	'page callback' => 'hotels_page_process_multiple_files_form_display',
	'access arguments' => array('view hotel menu items'),
	'weight' => 1,
	'file' => 'hotels_pages.php',
);

and

function hotels_page_process_multiple_files_form_display(){
	return drupal_get_form('hotels_page_process_multiple_files_form');
}

I was thinking I could probably make the form load before submit and some text afterwards with altering the form destination url to '?a=view' and placing the whole thing in an if-else loop like I've done with other modules. But I'm having trouble to find out how to force a different destination URL.

I found a module which could fix it, but I reckon it must be able to do it in the same way as I did with the encodingtype attribute like this: '$form['#attributes'] = array('enctype' => "multipart/form-data");'

Can anyone inform me how its possible to force this kind of attribute, as in, what the attributes name would have to be?

Thanks in advance!

Comments

ContentChris’s picture

I tried setting the redirect-attribute, but no luck so far. I must be giving it a wrong value.

$form['#attributes'] = array(
	'enctype' => "multipart/form-data",
	'#redirect' => ""
);

I tried using values like:

'http://xxx.xxx.xxx.xxx/drupal/hotels/hotels_process/process_multiple_fil...'
'process_multiple_files?a=view'
'?a=view'

All not giving the proper effect. It still shows the form after submitting it.
But I think it does need to be done with the redirect attribute.

ContentChris’s picture

Or perhaps I should add

$form['#action'] = url('hotels/hotels_process/process_multiple_files2');

Only this doesnt work together with ?a=view. I messes up the url, making it go to the parent page.