0
votes

I have a form that is created in a block in drupal, what I would like to do is display a result of the calculated values passed to the form in the same block.

  1. I render the form using

_block_view $blocks['content'] = drupal_render(drupal_get_form('form_name'));

  1. the form is displayed
  2. on form submit I do a calculation on the posted values
  3. from here I want to display the result in the original block

How do I capture the result and display it, or ideally display it under the form retaining the forms values?

1
You should capture the values in the form itself and add a form item element that will display the result in the same block/formBhavin Joshi

1 Answers

0
votes

OK what I did was add $form_state ['redirect'] = FALSE; to the submit handler, and the form populated itself, I then added a new form field with a readonly attribute and set #value to the calculated value utilising the values passed back inside $form_state['input']... also I omitted drupal_render( from the $blocks['content']= setting call above as it was not required