0

Below is my code. Form results are not displaying below the form. What am I missing ?

When I use print_r($form_state['storage']['results']); I'm getting the results.

But it is not displaying in the form.

Any ideas/suggestions will be helful.

function file_search_form($form,&$form_state) {
  $otpions = _get_country_titles();
  $form['countries'] = array(
    '#type' => 'select',
    '#title' => t('Country'),
    '#options' => $otpions,
    '#required' => TRUE,

  );
  $form['entities'] = array(
    '#title' => t('Entity'),
    '#type' => 'textfield',
  );

  if(isset($form_state['storage']['results'])) {
    $form['result'] = array
    (
      '#value' => t('The results of the form are: !results', array('results' => $form_state['storage']['results'])),
    );
  }

  $form['submit'] = array(
    '#value' => 'Search',
    '#type' => 'submit',
  );

  $form['#submit'][] = 'webform_options_submit';
  return $form;

}

function webform_options_submit($form, &$form_state) {

  $args = array(':entities' => '%'.$_REQUEST['entities'].'%', ':countries'=>$_REQUEST['countries']);
  $result = db_query("SELECT field_entity_value,field_country_value, filename
                   FROM field_data_field_entity,field_data_field_country , field_revision_field_file_upload, file_managed
                   WHERE ( field_data_field_entity.field_entity_value LIKE :entities
                   AND field_data_field_country.field_country_value= :countries )
                   AND field_data_field_entity.entity_id = field_revision_field_file_upload.entity_id
                   AND field_data_field_country.entity_id= field_data_field_entity.entity_id
                   AND field_revision_field_file_upload.field_file_upload_fid=file_managed.fid",$args );   
  foreach( $result as $item) {    
    $form_state['storage']['results'] = $item->filename;
  }
  $form_state['rebuild'] = TRUE;

}
0

Added type markup below the submit code in $form_state['storage']['results'] and that does the trick...

  $form['submit'] = array(
    '#value' => 'Search',
    '#type' => 'submit',
  );

if(isset($form_state['storage']['results'])) {
        $form['result'] = array
        (
          '#type' => 'markup',
          '#markup' => t('The results of the form are: !results', array('results' => $form_state['storage']['results'])),
        );
      }
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.