So far, the form is rendered in the block, but the following errors are displayed:
Notice: Undefined index: ios_lang_checkbox_nameform_function in drupal_retrieve_form()
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'ios_lang_checkbox_nameform_function' not found or invalid function name in drupal_retrieve_form()
<?php
function ios_lang_checkbox_block_info() {
return array(
'ios_lang_checkbox' => array(
'info' => t('Ios Like language switcher'),
'description' => t('Ios Like language switcher')
)
);
}
function ios_lang_checkbox_block_view($delta='')
{
$block['content'] = drupal_get_form('ios_lang_checkbox_nameform');
switch($delta) {
case 'ios_lang_checkbox':
$block['subject'] = null; // Most forms don't have a subject
$block['content'] = drupal_get_form('ios_lang_checkbox_nameform_function');
break;
}
return $block;
}
function ios_lang_checkbox_menu() {
$items['ios_lang_checkbox'] = array(
'title' => 'View the sample form',
'page callback' => 'drupal_get_form',
'page arguments' => array('ios_lang_checkbox_nameform'),
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM
);
return $items;
}
/**
* Define a form.
*/
function ios_lang_checkbox_nameform($form, &$form_state) {
$options = array(
'de' => t('de'),
);
$form['ios'] = array(
'#title' => t('Your Name'),
'#type' => 'checkboxes',
'#description' => t('Choose language'),
'#options' => $options,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
return $form;
}
?>
Thanks a lot!
_function
on the end ofios_lang_checkbox_nameform_function
...just change that line to$block['content'] = drupal_get_form('ios_lang_checkbox_nameform');
. The string passed todrupal_get_form
needs to be exactly the same as the function name itself, no need to put_function
on the end :)yourhost.com/ios_lang_checkbox
as defined in your menu?