Hi!

i need to embed entity add form in my module.

full path to default entity add form look like: http://*****/admin/structure/entity-type/gallery/gallery/add?destination

i have tried entity_ui_get_form('gallery', null, 'add');

but it throws me a lot of errors.

any advice? thank you.

Comments

muka’s picture

I used this:

  module_load_include('inc', 'eck', 'eck.entity');
  $form = eck__entity__add($entity_type_name, $bundle_name);
tomas.teicher’s picture

muka's solution #1 works for me too.

谢艳’s picture

Issue summary: View changes

hi, there is a problem,
how to set argument at eck add form?
er..... like drupal_get_form(),can set argument

qqboy’s picture

@muka
i used as you said, then we see the form, but click save but can not save data.
do you have the issue, or codes on your site work well and normally.

thanks.

caschbre’s picture

I'm having the same issue as qqboy. I added the two lines as in #1. The form renders but when I click save the entity is saved without any values. And the validation handler doesn't seem to run as required fields make it through blank/empty.

dimaboychev’s picture

This will work. but if your page callback is drupal_get_form you will have to take care of saving values yourself.

/**
 * Implements hook_menu().
 */
function test_menu() {
  $items = array();

  $items['test'] = array(
    'title' => 'Test',
    'page callback' => 'test_page',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function test_page() {
  $form = eck__entity__add($entity_type_name, $bundle_name);

  return $form;
}