0

I have an entityform that appears on a page, for some reason the form will not submit ...

// implement hook_menu

function foiagen_menu() {
  $items['node/%node/foiagen'] = array(
    'title' => 'Foia Generator',
      'description' => 'A foia generator form.',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('foiagen_form', 1),
      'access callback' => TRUE,
  );
return $items;
}

// embed the form (it's an entityform).

function foiagen_form($form, &$form_state) {
  module_load_include('inc', 'entityform', 'entityform.admin');
  $entity_form_name = 'foia_generator';
  $render_estimate_form =
    entityform_form_wrapper(entityform_empty_load($entity_form_name), 'submit', 'embedded');
  $form['foiagen'] = $render_estimate_form;
  return $form;
}

function foiagen_form_validate($form, &$form_state) {
}

function foiagen_form_submit($form, &$form_state) {
}

I have tried to wrap my head around this solution but cannot figure out where, once my form is rendered, filled and the submit button pressed the 'update' occurs that makes the input void...

I have seen the comment here and tried adding

 $form['#token'] = NULL;

to my 'function foiagen_form' that does circumvent the 'The form has become outdated.' error but leads to a blank page. Indicating that perhaps something else altogether is malfunctioning.

following direction from answer came up with this:

function foia_generator_form($form, &$form_state) {
  form_load_include($form_state, 'inc', 'entityform', 'entityform.admin');
  $entityform = entity_create('entityform', array(
    'type' => "foia_generator",
  ));
  $form = entityform_form_wrapper($entityform);
  return $form;
}
2

1 Answer 1

1

It looks like you may have a hook namespace collision with hook_form().

Although that might only be called if you're defining a node type, it's probably worth using a more specific function name for your form builder (e.g function foiagen_generator_form). Also make sure you're returning the form build array (array of elements), and not the rendered form in your form build function.

3
  • Form constructors always get $form, in Drupal 7; see path_admin_form(). It is not different from validation and submission handlers.
    – apaderno
    Jul 16, 2014 at 2:55
  • @kiamlaluno, Thanks for the clarification, will keep that in mind! Jul 16, 2014 at 3:15
  • Thanks, I came up with something that I actually understand from your pointers. Still having problems but will ask another question about that. Jul 16, 2014 at 21:33

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.