Skip to content

Instantly share code, notes, and snippets.

@DuaelFr
Created December 31, 2015 11:13
Show Gist options
  • Save DuaelFr/b463ec037668748f8870 to your computer and use it in GitHub Desktop.
Save DuaelFr/b463ec037668748f8870 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