Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Last active August 29, 2015 14:24
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 vijaycs85/00171ad8b3ff233c8a1f to your computer and use it in GitHub Desktop.
Save vijaycs85/00171ad8b3ff233c8a1f to your computer and use it in GitHub Desktop.
<?php
// playground.module file.
/**
* Implements hook_form_FORM_ID_alter().
*/
function playground_form_user_login_block_alter(&$form, &$form_state) {
$form['preference'] = array(
'#type' => 'select',
'#options' => array(
'test',
'test1',
'test2',
'test3',
),
'#multiple' => TRUE,
);
$form['#submit'][] = 'playground_form_user_login_block_sumbit';
}
function playground_form_user_login_block_sumbit($form, &$form_state) {
print_r($form_state['values']);exit;
}
// After selecting first 3 option and submitting form will give:
Array
(
[name] => username
[pass] => password
[submit] => Log in
[form_build_id] => form-gwDOjVttTr6yEM1ZmNmUFmAPH3PO2MyFJ2O_c6SqUM0
[form_id] => user_login_block
[preference] => Array
(
[0] => 0
[1] => 1
[2] => 2
)
[op] => Log in
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment