custom form handling for n00bz

Events happening in the community are now at Drupal community events on www.drupal.org.
d00bz's picture

This question is about how to create/manage a compound CCK element, allowing simulataneous creation/editing of the parent node and its children in a single form.

I have a CCK type (Project) that I want to be the parent class for a set of child elements (Benchmarks). the existing CCK "Motif" seems to allow me to create an array type under project that helps me to "Find" existing chlld elements. What I want to be able to do is create a project AND a series of child benchmarks (or at least one!) in one fell swoop.

I figured out how to customize (theme) the Project form to create the fields I need (an array of five stock possible benchmarks) -- but I am having trouble figuring out how to alter the code to interpret / create/ edit these five benchmarks and route you back to the benchmark view page.

Any hints/tips/links?

Comments

Webform module?

burt.lo's picture

I attended the monthly San Diego Drupal User Group meeting on Wednesday and I was given the suggestion of the webform module for handling forms in general. I haven't had a chance to play with it yet, but maybe that'll give you more to work with than you have now. Another module that was suggested was the EvalWF for for evaluating forms.

http://drupal.org/project/webform
http://drupal.org/project/evalwf

Good luck, and share what you find if you can. Thanks!

Project Management: http://www.sagetree.net
Coaching Services: http://burtlo.info

wait

kscheirer's picture

So when you create a new project node, you also want 5 benchmark nodes to be created as well? That's something you could do with Rules/Triggers/Actions. When a certain thing is true (the trigger), you can define actions that you would like Drupal to take. In this case, the trigger is a new Project node was created, and the action would be to create 5 new Benchmark nodes.

For context here's a shot

d00bz's picture

Only local images are allowed.

I have customized the project form to add benchmark fields. What I can't figure out is which hook I need to write / modify in order to translate the ten fields I've added (5 dates and 5 descriptions) into separate records.

I would like to know if there is a codeless way I can make the form create slots for my child (benchmark) class but failing that I'll have to continue my crrent course and customize the form with code.

  • the idea is that the first time the form loads, five slots for benchmarks are loaded.
  • When the form is saved, I interpret the POST into 5 benchmark records.
  • If the form loads again, I populate my manual fields from the database of benchmarks.

Does this make sense?

Are the Benchmarks just a

kscheirer's picture

Are the Benchmarks just a pair of fields (date + description)? In that case, use CCK to add 5 date fields and 5 description fields to your Project content type. The data will automatically be stored for you, and retrieved when viewing or editing the Project node.

They are seperate nodes

d00bz's picture

I have given up on CCK and am approaching the problem with custom module node types.
While I want to "seed" the form with five slots for new (related) benchmarks, I want an arbitrary number of benchmarks.

If I were to CCK this project I need some way to load, edit and save a parent node type and five (or more) related nodes in one swipe which may not be beyond the ability of CCK but is at this point beyond my ability to implement via CCK.

in that case

kscheirer's picture

So the relationship you want to model is that there are 2 content types, Project and Benchmark. You can use nodereferences to model this. This is a CCK field that lets you store a reference to an existing node. That gets you halfway to your goal - the relationship is correct, but the Benchmarks have to exist first, before the Project.

Next you can use a module like Popups: Add and Reference (http://drupal.org/project/popups_reference). So when you're creating the Project node, you can add and reference the Benchmark nodes in a popup window. This way they don't need to be created first.

Hope that helps!

SF Bay Area

Group categories

Resources

user group

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: