0

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?

apaderno
  • 28,547
  • 16
  • 75
  • 90
Darren
  • 21
  • 5
  • You should capture the values in the form itself and add a form item element that will display the result in the same block/form – Bhavin Joshi Apr 24 '13 at 04:16

1 Answers1

0

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

Darren
  • 21
  • 5
  • I need to do something similar, but I need more help than what you asked for. Can you post the whole source code please? – Fernando Pap Apr 13 '16 at 13:39