Drupal 7 Forms

Build a form with the Form API

For reference:https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...

function YOURMODULENAME_anyname_form($form, &$form_state){
    // markup, in this case, an in-line <label>
    $form['namelabel'] = array(
        '#type' => 'item',
        '#markup' => '<label for="name">Full Name</label>',
    );
    //Text Field
    $form['name'] = array(
       '#type' => 'textfield',
    );
    $form['submit'] = array(
       '#type' => 'submit',
       '#value' => t('Submit A Claim'),
       '#weight' => 4,
    );
    $form['#action'] = url('YOUR-FORM-PROCESSING-URL');
    return $form;
}

How to call and render this form

$myForm = drupal_get_form('YOURMODULENAME_anyname_form');

You can render the form directly:

drupal_render($myForm);

Or return an output to a calling function. See methods A and B below:

Method A: Return a rendered form

$output = drupal_render($myForm);

Method B: Return a form object

You can also return the form object, and do the render on the calling function:

$output = $myForm;

Calling function:

function YOURMODULENAME_somefunction() {
   // Method A
   $claimForm =  drupal_get_form('YOURMODULENAME_anyname_form');
   $claimFormDisplay = drupal_render($claimForm);
   return $claimFormDisplay;
}
function YOURMODULENAME_somefunction() {
   //Method B
   $claimFormDisplay =  drupal_get_form('YOURMODULENAME_anyname_form');
   // we already received a rendered form, so we can return this value to a hook_menu call back
   return $claimFormDisplay;
}