Skip to main content
deleted 39 characters in body
Source Link
Jaypan
  • 18k
  • 3
  • 34
  • 65

Hook_forms hook_forms() not working

I'm trying to add a button to all node forms via callback in hook_forms. I get a similar error. Can someone help.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'my_dossier_form' not found in drupal_retrieve_form() (line 844 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1094 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1108 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1128 of /var/www/includes/form.inc).

Code

function my_dossier_forms($form_id, $args) {
  $forms = array();
  if ($types = node_typ[![enter image description here][1]][1]e_get_typesnode_type_get_types()) {
    foreach (array_keys($types) as $type) {
      $forms[$type . '_node_form']['callback'] = 'my_dossier_form';
    }
  }

  return $forms;
}

function my_dossier_form($form, &$form_state) {
  $form['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#weight' => 10,
  );
  return $form;
}

Hook_forms not working

I'm trying to add a button to all node forms via callback in hook_forms. I get a similar error. Can someone help.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'my_dossier_form' not found in drupal_retrieve_form() (line 844 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1094 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1108 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1128 of /var/www/includes/form.inc).

Code

function my_dossier_forms($form_id, $args) {
  $forms = array();
  if ($types = node_typ[![enter image description here][1]][1]e_get_types()) {
    foreach (array_keys($types) as $type) {
      $forms[$type . '_node_form']['callback'] = 'my_dossier_form';
    }
  }

  return $forms;
}

function my_dossier_form($form, &$form_state) {
  $form['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#weight' => 10,
  );
  return $form;
}

hook_forms() not working

I'm trying to add a button to all node forms via callback in hook_forms. I get a similar error. Can someone help.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'my_dossier_form' not found in drupal_retrieve_form() (line 844 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1094 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1108 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1128 of /var/www/includes/form.inc).

Code

function my_dossier_forms($form_id, $args) {
  $forms = array();
  if ($types = node_type_get_types()) {
    foreach (array_keys($types) as $type) {
      $forms[$type . '_node_form']['callback'] = 'my_dossier_form';
    }
  }

  return $forms;
}

function my_dossier_form($form, &$form_state) {
  $form['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#weight' => 10,
  );
  return $form;
}
Source Link

Hook_forms not working

I'm trying to add a button to all node forms via callback in hook_forms. I get a similar error. Can someone help.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'my_dossier_form' not found in drupal_retrieve_form() (line 844 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1094 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1108 of /var/www/includes/form.inc).
Notice: Array to string conversion in drupal_prepare_form() (line 1128 of /var/www/includes/form.inc).

Code

function my_dossier_forms($form_id, $args) {
  $forms = array();
  if ($types = node_typ[![enter image description here][1]][1]e_get_types()) {
    foreach (array_keys($types) as $type) {
      $forms[$type . '_node_form']['callback'] = 'my_dossier_form';
    }
  }

  return $forms;
}

function my_dossier_form($form, &$form_state) {
  $form['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#weight' => 10,
  );
  return $form;
}