I have three content types that each have a number of CCK fields and are related to each other in 1 to many relationships. (ex: vs_trip 1=* vs_site 1=* vs_observation).
Our design team wants this setup as a multi-part tabbed form.
Tab 1: Define (or select or copy) the Trip
Tab 2: Define a site
Tab 3: Define 1 or more observations
Tab 4: A review page that combines the data from all of the other tabs into a single long page (users can click on the content to bring up an edit field for the clicked field content)
Additionally, at the top of tab 1, they want another form that allows the user to select an existing trip to copy.
Also, some of the fields (ie. the nodereference fields that define the relationships) shouldn't be visible to the user as they will be populated programmatically.
Finally, I don't want to change the base admin forms since we want the site administrators to be able to look at and modify the raw content through the admin section of the site.
So my questions are:
1. What is the best way to setup the tab navigation?
2. Do I have the tabs reference the built-in Drupal forms for each content type or do I build a custom form and programmatically create the content from the custom form?
3. How do I insert the Copy/Select form above the new Trip form on Tab 1 (maybe a custom Theme function?)
4. What's the best practice for hiding form fields and populating them programmatically?
My initial approach, which isn't working, was to define a new menu entry for the tabbed data entry form and then to try programmatically retrieving and modifying the built-in form for each content type before displaying on the page. But it doesn't seem like you can use drupal_get_form() to retrieve the content add/edit forms. (ex: calling drupal_get_form('vs_trip_node_form') returns a callback error.
Likewise, trying to copy the form definition from the edit form and putting it in a custom form function that is called by drupal_get_form() doesn't render the CCK fields.
Thanks for any suggestions you have.
Comments
progress?
Any luck figuring this out? I'm currently trying to research how to have multiple content type forms show up on the same page for a user to use.
I've gone down several
I've gone down several different paths on this over the last couple weeks.
My current path is using hook_form_alter() to modify the forms with a custom menu bar to represent the tabs.
The process (which is working pretty well) is as follows:
-Use hook_menu() to add an entry point to my form processing sequence. It basically just redirects to the /node/add/type form and appends a parameter (/so) to indicate that we're in the form processing sequence (as opposed to an admin going directly to the edit forms).
-Use hook_form_alter() to detect the /so parameter in the URL, if found modify the form to preset or hide fields as needed. I also change the text on the submit buttons and add additional buttons. Finally, I add an extra action to the '#submit' handler on each button. This extra handler takes care of redirecting to the next form in the sequence and passing along any information that is needed.
I haven't tackled the final review screen yet. That will probably be a completely custom form using an inline editing module I've been working on.
Thanks,
Shawn
Thanks for the update.
Hopefully, I'll have some time this weekend to try your solution, though it sounds like I'll need to learn/review more about Drupal and the form sequence.
subscribe
subscribe
subscribe
subscribe
Subscribe
Subscribe