0

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!

8
  • 2
    You've left _function on the end of ios_lang_checkbox_nameform_function...just change that line to $block['content'] = drupal_get_form('ios_lang_checkbox_nameform');. The string passed to drupal_get_form needs to be exactly the same as the function name itself, no need to put _function on the end :)
    – Clive
    Sep 12, 2012 at 17:47
  • 1
    What @Clive said, as I was about to ask are you sure it's showing up in the block and not the page, eg on page yourhost.com/ios_lang_checkbox as defined in your menu?
    – Jimajamma
    Sep 12, 2012 at 17:49
  • @Jimajamma thanks for asking. As far as i understand it i implemented both...do I ? I really don't see how I should gasp all that cryformommy
    – Jurudocs
    Sep 12, 2012 at 17:53
  • @Clive why dont you put it togeher into an answer? Than i can at least give you some points for you extraordinary nice help
    – Jurudocs
    Sep 12, 2012 at 17:55
  • 2
    @Jurudocs Get yourself a copy of Pro Drupal Development, it's got pretty much everything you need to know in it
    – Clive
    Sep 12, 2012 at 18:07

1 Answer 1

2

You've got _function on the end of ios_lang_checkbox_nameform_function...just change that line to:

$block['content'] = drupal_get_form('ios_lang_checkbox_nameform');. 

The string passed to drupal_get_form() needs to be exactly the same as the function name itself, no need to put _function on the end :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.