Created
December 31, 2015 11:13
-
-
Save DuaelFr/b463ec037668748f8870 to your computer and use it in GitHub Desktop.
Drupal GET form without tokens/op in one function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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