By maozet on
How do i reference one content type to another content type.
I have created a two modules which create content type.
1) Manufacturer
2) Countries
What is the proper way to reference a manufacturer to a country?.
For example:
1) when a new manufacturer form is displayed, how do i display a list of countries to choose from in node/add/manufacturer ??
2) In the manufacturer.install scheme, how should i declare the country field type?
regards,
Comments
have you ever try cck? i
have you ever try cck? i think it really helpful for your case. there's node reference field if you referencing another node and you also can create your own select list from an array that may gathered from SQL query.
CCK Node Reference
CCK Node Reference
To add to my last comment, if
To add to my last comment, if you want to make this field part of install.... I spent some time figuring this out recently(how to add a CCK field as part of install), and it wasn't an easy issue.
I found this worked:
1. Create a Content Type with the field you want (node reference)
2. Use Content Type Export to get the definition of that field
3. Put that definition in a variable and on install create it: something like http://drewish.com/node/118
4. OR just use content type IMPORT (#3 is just if you want it to happen on Install)
What if i don't want to user CCK?
How do i do it with hook_form?
Someone can correct me, but
Someone can correct me, but to my knowledge there is no way to add a CCK $form value in hook_form. Would love to be wrong.
If you look in the database at the definition of a CCK field you will see that there is a lot of involved, and that the form API does not cover that.
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html
I would be willing to contributor to a hook or module that made this possible. ( in case anyone is listening :-)