Hi,

I have a the standard form setup :

function module_search_simple_form()
{
	$form = array();
	
	$form['search'] = array(
		'#type' => 'fieldset',
		'#title' => t('Simple Search'),
		'#collapsible' => FALSE,
		'#collapsed' => FALSE,
		'#tree' => TRUE,
	);
	
	$form['search']['simple'] = array(
		'#type' => 'textfield',
		'#size' => 25,
		'#maxlength' => 150,
	);
	
	$form['search']['submit'] = array(
		'#type' => 'submit',
		'#value' => t('Search'),
	);
	
	return $form;
}

function module_search_simple_form_submit($form, &$form_state)
{
	drupal_set_message('VALUE : ' . $form_state['values']['search']['simple']);
        
        echo "<table><tr><td>Hello World</td></tr></table><br>";
}

function module_search_simple_page() {
	return drupal_get_form('module_search_simple_form');
}

function module_search_block($op = 'list', $delta = 0, $edit = array()) 
{
	switch ($op) 
	{
		case 'list':
			$blocks[0]['info'] = t('Module Search Block');
			return $blocks;
		case 'view': default:.
			$block['subject'] = t('Search for Establishments');
			$block['content'] = drupal_get_form('module_search_simple_form') . "<p align='center'><a href='advancedsearch'>Advanced Search<a></p>";
			return $block;
	}
}

I am trying to take it to a page with just a standard output from a database but I am unable to display html text in the _submit section. I can get the results and I can post it to a database, that works great. But I cannot get it to display the html as seen above where the "Hello World" is.

The next problem is I am posting this from a block and it doesn't post it to a new page? Any ideas as to how I can action that.

My third question is, how do I get a form to instead of sending the results through as a POST, send it through as a GET. I am wanting to page the results and if I use a POST it's going to ask me to post the search query each time I press back or forward.

Any assistance would be greatly appreciated.

Kind Regards,
Davin

Comments

Trappies’s picture

Hi, anyone have any ideas about the above post? Been trying to figure it out all day now :(

Any assistance will be greatly appreciated :)

Davin

Trappies’s picture

bump :)

Trappies’s picture

bump again :)

Trappies’s picture

Bump.... yet again....

leda.ch’s picture

Hi,

I have the same problem. But now, after many hours of headscratching I may have found a solution, as it seems to work:

1. Add a new item in hook_menu:

$items['my_result'] = array('title'                         => 'My Result',
   	                                      'page callback'         => 'now_my_result',
    	                                      'access arguments' => array('my_res'),
                                              'type'                       => MENU_CALLBACK,
	                                    );

2. Add a new function to your module:

function now_my_result()
{
        return '<p>'. t('The quick brown fox jumps over the lazy dog.') .'</p>';
}

3. Call it from your hook_submit:

function sample_submit($form, &$form_state)
{
	$form_state['redirect'] = 'my_result';
}

Hope it helps
rgds
leda