I'm building a custom form that will show some details from a web service.
On my page callback I have two fields and submit button:
<?php
$form['starting_date'] = array(
'#type' => 'date_popup',
'#title' => 'Starting date',
'#date_format' => 'd.m.Y',
);
$form['end_date'] = array(
'#type' => 'date_popup',
'#title' => 'End date',
'#date_format' => 'd.m.Y',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Check'),
'#submit' => array('reports_list'),
);
On
<?php
function reports_list($form, &$form_state) {
}
I'm inserting the code that connects with the web service, passing the form_state values of selected dates and after that I'm trying to display the table with the web service details on the same page, but after clicking on submit it simply refresh the page and doesn't show anything.
I can see connecting with the web service is successful.
On custom submit function this for an example is not displaying:
<?php
$form['results'] = array(
'#type' => 'markup',
'#markup' => '<p>TEST</p>',
);
I'm doing something wrong, I guess...
EDIT: I've tried to display something in the submit function like this:
<?php
$form['results'] = array(
'#type' => 'markup',
'markup' => 'TEST10',
);
echo render($form['results']);
It's not working.
date_popup
element is wrong. It must be'date_popup'
instead ofdate_popup
$form
array in submit callback. instead just display message. Or if you want to create another$form
array, you need to render it withrender()
function.drupal_set_message()
function then.