Skip to content

Instantly share code, notes, and snippets.

@flocondetoile
Forked from DuaelFr/mymodule.module
Created March 23, 2016 12:06
Show Gist options
  • Save flocondetoile/3f9d78871f3da8cf0e62 to your computer and use it in GitHub Desktop.
Save flocondetoile/3f9d78871f3da8cf0e62 to your computer and use it in GitHub Desktop.
Drupal GET form without tokens/op in one function.
<?php
function mymodule_myform($form, $form_state) {
$form = [
'#method' => 'GET',
'#action' => url('my_search_page'),
'#token' => FALSE,
'#after_build' => [
function($form) {
$form['form_token']['#access'] = FALSE;
$form['form_build_id']['#access'] = FALSE;
$form['form_id']['#access'] = FALSE;
return $form;
},
],
];
$form['field1'] = [...];
$form['field2'] = [...];
$form['actions'] = [
'#type' => 'actions',
'submit' => [
'#type' => 'submit',
'#name' => '',
'#value' => t('Submit'),
],
];
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment