0

I have created a module i can use to create multiple blocks, now with one of those blocks, there is a requirement for a form (which the user needs to be able to see). However, this does not require any Drupal "Save" interactions.

Its a very simple static form that is manipulated with Ajax functionality. I have just coded this form simply within the TPL file.

<form name="formelement" method="post">
    <input name="data" type="hidden" value="" />
    <div class="something_here">something here</div>
    <div class="something_here">something there</div>
    <input required="" type="text" class="" name="blah1">
    <input required="" type="text" class="" name="blah">
    <div>
        <button type="submit" class="btn" href="">submit</button>
    </div>
</form>

Question - I need to be able to get the $_POST in a function - what would be the best method of creating this form with the .module file or the drupal 7 api and then print it within the tpl file

1 Answer 1

0

You can create form by develop custom module then you use developed form any where in node or block.

Create a custom module

  • Create a file sites/all/modules/own/form_test/form_test.info
  • Create a file sites/all/modules/own/form_test/form_test.module

(start it with <?php tag, but don't add ending ?> tag)

function form_test_form($form,&$form_submit) {
  $form['firstname'] = array(
    '#title' => t('Firstname'),
    '#type' => 'textfield',
    '#required' => TRUE,
  );
  $form['lastname'] = array(
    '#title' => t('Lastname'),
    '#type' => 'textfield',
  );
  $form['submit'] = array(
    '#value' => 'Submit',
    '#type' => 'submit',
    );
  return $form;
}

More details

1
  • thanks for that information. When looking into the details page that you posted, it stated that the new page is being created with the menu hook. How can i call it within an existing template but have a callback functionality.
    – jagmitg
    Commented Nov 13, 2015 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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