3

I am using ECK I create one form through entity->bundle->feedbackform->managedfield my form is created, but how to get form path, current path is of my feedback form is:- admin/structure/entity-type/feedbackform/feedbackform/add but this path is not for anonymous user. i want to show my form to anonymous user with some simple path

3 Answers 3

4

Assuming you have a module called 'helloworld', and entity type called 'vechile' and a bundle called 'car'.Here is some code that should do the trick.

/**
 * Implements hook_menu().
 */  
function helloworld_menu(){
$items['feedbackform'] = array(
'page callback' => 'example_my_eck_form_page',
'access arguments' => array('Access feedback form'),// permission
'type' => MENU_CALLBACK,
);
return $items;
}

function example_my_eck_form_page(){
   module_load_include('inc', 'eck', 'eck.entity');  
   $bundle_name='car';
   return eck__entity__add('vechile', $bundle_name);   
}


function helloworld_permission() {
   return array(
    'Access feedback form' => array(
      'title' => t('Access feedback form'),
    )
  );
}

Access feedback form is a custom permission so you still would have to give that permission to the users from admin to be able to access the path.

0

I haven't tried this with ECK, but I believe that the behaviour should be the same as with any other form. You would simply need to:

  • Register a menu callback in a custom module for the "simple path", accessible to anonymous user role (see hook_menu())
  • The 'page callback' can either be
    • a custom function 'example_my_eck_form_page', where you return drupal_get_form('eck_name_of_your_form');
    • or 'drupal_get_form' and pass the form name in 'page arguments' array.
0

There is a module for that: https://www.drupal.org/project/eck_pm

Alternatively you could use hook_entity_info_alter like so:

function MYMODULE_entity_info_alter(&$info) {
  if (isset($info['ENTITY']['bundles']['BUNDLE'])) {
    $info['ENTITY']['bundles']['BUNDLE']['crud']['add']['path'] = 'my/public/path';
  }
}

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.