brrocks28
6/6/2016 - 11:44 AM

Play with TPL (Render a form with TPL) //Refer yoy google drive for sample module

Play with TPL (Render a form with TPL)

//Refer yoy google drive for sample module

//.module file
function custom_module_menu() {

  $items['example'] = array(
    'title' => 'Example Page',
    'page callback' => 'custom_module_page',
    'access arguments' => array('access content'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

function custom_module_page () {
	$user_id = '1';
	$output = theme('my_account', array('my_profile' => $user_id, 'i' => 1));
		$output2 = theme('my_account', array('my_profile' => $user_id, 'i' => 2));

	$output3 = theme('my_account', array('my_profile' => $user_id, 'i' => 3));

    return $output.$output2.$output3;
}

function custom_module_theme() {
	   return array(
       'my_account' => array(
           'template' => 'templates/contact-site-form',
           'arguments' => array('my_profile' => NULL),
       ),
   );
}

function custom_module_preprocess_my_account(&$variables) {
	$form=drupal_get_form('my_form', $variables['i']);
	$variables['form'] = $form;
	dsm($variables);
}

function my_form($form, &$form_state, $i) {
dsm($i);
   $form['reshipment_checkbox'.$i] = array(
        '#type' => 'checkbox',
        '#title'=>'Reship',
    );
   $form['reshipment_button'] = array(
        '#type' => 'submit',
        '#value'=>'Reshipment',
    );   

return $form;
}

function my_form_submit($form, &$form_state){
	dsm($form_state);

}
//.info file
name = Custom Module
description = Description of the module.
core = 7.x

; Information added by Drupal.org packaging script on 2014-10-18
version = "7.x-1.x-dev"
core = "7.x"
project = "drupal_module_boilerplate"
datestamp = "1413658731"

//create custom tpl in templates/contact-site-form.tpl.php

<?php print drupal_render($form);?>