Skip to content

Instantly share code, notes, and snippets.

@weeger
Created August 20, 2016 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weeger/d2025ecffbb94c2c8b509ff821a958d0 to your computer and use it in GitHub Desktop.
Save weeger/d2025ecffbb94c2c8b509ff821a958d0 to your computer and use it in GitHub Desktop.
Create a custom form template in Drupal 7.x
function YOURMODULE_form($form, &$form_state) {
  $form           = array();
  $form['myfield'] = array(
    '#type'     => 'text',
    '#value'    => 'Do Cool Things',
  );
  return $form;
}
/**
 * Implements hook_theme().
 */
function YOURMODULE_theme($existing, $type, $theme, $path) {
  return array(
    'YOURMODULE_form' => array(
      'render element' => 'form',
      'template'       => 'form-template-name',
      'path'           => $path . '/templates'
    ),
  );
}
@LANDOLSIAMINE
Copy link

that's good but ajax does'nt work also the submit button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment