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

时间:2013-02-23 12:02:59

标签: drupal-7 entity drupal-modules drupal-views

我在drupal中创建了一个带有实体的自定义模块。我已经安装了实体api模块。我通过employee_management.install文件(其中employee_management是我的自定义模块名称)的帮助创建了我的数据库模式,只有两列(employee_id,first_name),employee是我的实体名称。

我还编写了必需的函数employee_management.module,但它仍然显示错误,每当我尝试在admin / structure / employee中添加一个新实体时,它会向我显示以下错误:“Not Found”。

在此服务器上找不到请求的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 个答案:

答案 0 :(得分:1)

您不会自动获取创建实体的路线和表单,您必须自己实施。请参阅hook_menuthis guide