2013-02-23 103 views
0

我已经在实体的drupal中创建了一个自定义模块。我已经安装了实体API模块。我通过employee_management.install文件(其中employee_management是我的自定义模块名称)的帮助创建了只有两列(employee_id,first_name)的数据库模式,employee是我的实体名称。在此服务器上找不到请求的URL/drupalhr/drupal/employee/add/

我也写了必要的函数employee_management.module,但它仍然显示我的错误,每当我试图添加一个新的实体在管理员/结构/员工它向我显示以下错误:“未找到”。

在此服务器上找不到请求的URL drupal/employee/add /。

function employee_management_entity_info() { 
    $employee_info['employee'] = array(
    // A human readable label to identify our entity. 
    'label' => t('Employee Entity'), 
    // The controller for our Entity - extends the Drupal core controller. 
    'controller class' => 'EmployeeController', 
    // The table defined in hook_schema() 
    'base table' => 'employee', 
    // Returns the uri elements of an entity 
    'uri callback' => 'employee', 
    // Fieldable that we can attach fields to it - the core functionality will 
    // do the heavy lifting here. 
    'fieldable' => TRUE, 
    // The unique key of our base table. 
    'entity keys' => array(
     'id' => 'employee_id', 
    ), 
    // FALSE disables caching - caching functionality is handled by Drupal core 
    'static cache' => TRUE, 
    // Attach bundles - i.e. alternative configurations of fields associated with a main entity. 
    'bundles' => array(
     'employee' => array(
     'label' => 'Employee', 
     // Information below is used by the Field UI - they "attach" themselves here and lets us 
     // do the standard field management that all the core entities enjoy. 
     'admin' => array(
      'path' => 'admin/structure/employee/add', 
      'access arguments' => array('administer employee entities'), 
     ), 
    ), 
    ), 
    // View modes allow entities to be displayed differently based on context. We simply have one option 
    // here but an alternative would be to have a Full and Teaser mode akin to node. 
    'view modes' => array(
     'full' => array(
     'label' => t('Full'), 
     'custom settings' => FALSE, 
    ), 
    ) 
); 

    return $employee_info; 
} 

编辑

function employee_uri($employee) { 
    return array(
    'path' => 'employee/' . $employee->employee_id, 
); 
} 

这里是功能的完整列表,在文件employee_management.module

回答

1

你不会自动地获取途径和形式,以创建实体,你必须自己实现它。见hook_menuthis guide

相关问题