5

For our final CS project, we have been tasked with building a project management system for a large corporation (which the company wants us to use Drupal). So far we have a few entities created (project, request, and task). A project can have many tasks, and a project can only have one request attached (the request is created first, once approved, a project is created).

Since Drupal is really more of a content (blogs/comments/articles/pages) management system, it is difficult to create dynamic forms that allow showing tasks attached to a project with the ability to add tasks directly within the project "form". I guess this would kind of be a master/detail view.

How can I go about building these types of add/edit/details "forms"? My first two ideas are:

  1. Build custom add/edit/delete forms for each entity type
  2. Build a node-add-project.tpl.php, node-edit-project.tpl.php, etc... for each complex view required

The downside to this is that my fields in my forms are now hard-coded. One requirement is that this system must be dynamic so the end-user can add a field if they need to.

How can I go about this? Templates? Custom Forms?

By the way I have googled, and googled, and googled (probably 5-8 hours) of different things (master details, complex forms, complex entity relationship forms) to no avail.

I am aware of the nodereference and entity reference (and all other reference) types. But these only allow you to use a dropdown list, or a select list, etc...

EDIT:

It is looking like building the database with the Schema API, and utilizing the Form, Theme, and security APIs are going to be our best bet.

Here is a good read.

6
  • Node Reference module also allows you to use a text field that will suggest what you're looking for, as you type, from database (much like Google's autocomplete suggestions). Is that useful for you, or what do you have in mind?
    – dxvargas
    Feb 14, 2012 at 11:21
  • Not really, one of the requirements is the ability to add tasks to a project (easily) - from the view project screen. So having to create a new task, and then specify the project doesn't really make sense (especially if you just CAME from that project).
    – Jack
    Feb 14, 2012 at 14:28
  • drupal.org/project/nodereference_url may help with that situation; you can create a link that will automatically set the nodereference field value based on a url parameter to the node form.
    – gapple
    Feb 15, 2012 at 0:07
  • Do you need to do this all programatically? If so there are a ton of API's which could support you, I would suggest taking a look. If you want it dynamic would it be cheating to use modules like Display Suite (this really sorts out a lot of tpl.php requirements) so you can customise the display of each nodes type...
    – WestieUK
    Feb 15, 2012 at 12:29
  • IS it necessary to use entity, as looking at your requirement You can do all this with creating contain type and you do not need to do everything with coding in CMS like drupal.
    – j2r
    Feb 20, 2012 at 11:19

2 Answers 2

1

Not exactly what you asked: Are you sure you want/must build this with Drupal? If you have to, have a look at entities. Be prepared to live with young and not perfect documented features. Entities are the Drupal thing of business classes. Nodes are one incarnation of them to manage content.

2
  • Ultimately this is what I had to do. Yes this must be developed with Drupal (my professor, and the businesses requirements). It's actually working out quite nicely, now, instead of having hacked together "content types" linked with references, I have complete control over my entities defined by hook_schema and hook_entity_info, including fieldable entities to allow for dynamic fielding. Not sure how this will work with reporting though, will be an interesting semester :).
    – Jack
    Mar 1, 2012 at 3:50
  • You can use fields and views with entities. This requires some extra work but especially views commes in very handy when you need report and overview screens. What is sometimes a good aproach to find code examples is to find a contrib module which is using your approach.
    – BetaRide
    Mar 1, 2012 at 7:32
5

You should be able to duplicate this functionality using the Field Collection module.

In short, you attach a Field Collection field to an entity, and then define the Field Collection in a separate UI (/admin/structure/field-collections) by attaching additional fields to it. It will behave like (and is in fact internally represented as) a first-class entity, and the module allows you to manage these items from the same parent form you attached the Field Collection field to, complete with drag-and-drop for reordering and the like. It also has a number of other nice features, such as letting users with appropriate permissions add/edit/delete Field Collection items while viewing the parent node without having to go into the edit form itself.

1
  • I will take a look, when I looked at it initially it didn't seem to do what I need, but this could in fact be very handy. Thanks!
    – Jack
    Mar 1, 2012 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.