Hi Folks, I seem to have a lot of moving parts here so please bare with me in terms of complexity. This is as simplified as I can get it! I am looking for comments on my approach to a given issue:


I have a concept of 'Company', 'Branch' and 'Group'. These are all the same entity type, with a bundle created for each one.
Each hold unique data, as well as in the case of group and branch an entity_reference field to their parent.

I have the concept of 'employee'. An employee does not have an account on the site. An employee always has a reference to a group (and can only be in one group). I am considering making the employee another new fieldable entity. Ideally a site user would import employees from a csv with various data points (name, phone, job description, email etc) as part of setting up a new client on the system (a client being the company structure, employees, tasks the entire shebang).

A site user then needs to define a list of tasks. We need to record each users provided data against tasks. Questions are unique by company, but with variations by group. The 'answer set' is also unique by company.

Thus company 'Acme' has tasks 1,2,3,4 and 5. Group A's employees record answers to tasks, 1,2 and 4. Group B to 1,2,3 and 5.
The answer to task '1' is (or any task) is a one drop down list of values associated with company bundle (company_task_values).

The workflow is for a site user to associate a predefined employee with a predefined group, and then open that users 'task sheet'. this should present a number of fields to record data against the user (Many of these are defined in the company, branch and group). This will include all the tasks the company has that are assigned to the group, and to each task the answer must be recorded from the answer set. There is also freeform data to record against each task.


Firstly the above is pretty simplified - but it deals with the tricky bits.

This data set then needs to be available to be reported on in views, filtered by all the structural units and dates.
A site user needs to be able to effectively fill in task sheets for many users.
A employee has fields recorded against them that are global - such as status (task guide complete/task guide not complete/feedback on task guide provided) etc

So given the background, how would you approach it ?

My Thoughts:

Creating a 'survey form' (I say this as the results are not quite content) is easy enough - here however the form needs to by dynamically generated.
I think my first step is to create an entity called tasks, with a relationship to the company.

I then need an interface to add one to many tasks.

I guess I need a way of listing all of the companies tasks and making them active/inactive by group ? I probably need a status field on the group to mark it as 'complete' ?

Finally I need a way to open an 'employee', look up his group, retrieve a list of active tasks then present an 'answer' drop down, and a freeform text field against each one ?

Normally I do everything I need to through rules, views relations and a lot of site building. Although I can create entities with ECK, I guess this takes me into the territory of creating custom modules ?

I had originally planned to make the 'task guide' a content type. However with the addition of differing tasks by group (a new wrinkle just thrown at me) that no longer seems sensible.

Am I better off making everything its own entity / bundle combinations creating a crud, the relationships and then going from there ?

Is there any mileage in trying to use profile2 and a custom (by company) profile to store data for each user ? A future use case is having employees all log in with a unique link and fill in there own data.

Is entityform going to be able to help me out here ?

I can visualise the workflow, and most discrete parts - building the form dynamically seems like the hardest part - I had always worked on the idea of pre-creating it!

Can anyone think of any novel approaches to any of the component parts ?

Thanks in advance for any feedback!



Mizpah’s picture

Some progress made.

$basic = entity_get_controller('entityform_type')->create();
$basic->type = "entityform_test108";
$basic->label = "Test type 108";
$basic->data['notification_text'] = "Notification text";
$basic->data['roles'] = array(
3 => '3',
2 => '0',
1 => '0' ,
$basic->data['draftable'] = "0";
$basic->data['preview_page'] = "0";
$basic->data['redirect_path'] = "";
$basic->data['submission_show_submitted'] = "";


$field = array(
      'field_name' => 'field_108',
      'cardinality' => 1,
      'type' => 'number_integer',


$instance = array( 'field_name' => 'field_108', 'entity_type' => 'entityform', 'bundle' => 'entityform_test108', 'label' => 'FTest108', 'description' => 'Random integer field', 'required' => FALSE, );  


The above run from devel, will allow the entityform type to be created and the form submission works with the entity form and dummy field.

Now the challenges are to pull the correct datasets from the other entities, and dynamically create the fields/field instances, work out where this needs to live and be triggered from hook wise.