I'm creating a site for a car dealership and needed a form to add vehicles to the inventory. I have created a module with my custom form in it that collects all the information I need. I had to make a custom form because I needed to code in a hierachical select for make, then corresponding models and that is not supported with CCK (there is also a module for making hierarchical selects, but it hasn't been brought over yet to Drupal 6). I also have created a corresponding content type in CCK which matches the fields I defined in the custom form. Basically, I want to have my custom form submit all the information it's collected to the vehicle content type so that I will be able to use views on the inventory of vehicles.
I'm pretty sure that I need to do something in this part of the form:
function add_inventory_form_submit($form, &$form_state) {
// code that submits to CCK content type
drupal_set_message(t('This vehicle has been added to the inventory.'));
}
I also think that I may need to do something with drupal_execute, and/or something with exporting the CCK content type and using the code I get from that, but I'm stuck on what do do next (or even if that's how I should be going about this).
I've searched drupal.org and google, but I haven't been able to find anything that will help me put all the pieces together. Does anyone have any resources or examples that I could look at that may give me an idea of how to accomplish this? I'd appreciate any kind of help at all.
Comments
What I've done so far
Ok so I think what I'm looking for is something like this:
It's not working for me yet, However, I've been messing around with the database I'm pretty sure I've messed something up. I'm going to bed and I'll create a fresh database to test this tomorrow.
Similar to Webform Additional Processing
This is something similar to what I tackled recently using a Webform submission to generate a CCK node.
Note that I did a bit of tricky stuff to save the image that was on the form.
Update
In case anyone was following this, I wasn't able to get the form to submit to a node the way I wanted. I just couldn't find documentation or relevant examples that I could understand. I ended up finding a way to get Conditional Fields to work, solving my original problem, and now I add inventory to the site using the CCK.