Dear all,
I would be grateful if you could give some information as to how to insert a hook_form.
I’ve been using Drupal for a month or so in order to build a small bibliography. The bibliograhy module is really flexible – a very good module indeed -- but there are too many textfields available for the users. I would like to display only some of them.
A guy who has the same problem posted a snippet last week and said to insert it in a “hook_form” in order to hide some of the fields.
I don’t know what "insert in a hook form" means, that is which steps I have to undertake. I found the "hook_form" in the Drupal API, but now do I have to copy the snippet code? And to create a page in the module? Do I need to implement the hook? How?
I haven’t been able to find a specific documentation and I don’t know if it's too difficult for a beginner. Could you help me either telling me what to read or explaining the steps I have to follow, please?
Thanks,
calimera
Comments
hook_form() is only used for
hook_form() is only used for building content types. It's doubtful you need it, as you would probably already know you were supposed to be using it in such a case.
I think it's more likely he was trying to tell you to use the forms API and just didn't really know what he was talking about.
Anyways, if you tell us more about what you are talking about, maybe we can give you a hand on pointing you in the correct direction.
Contact me to contract me for D7 -> D10/11 migrations.
Thank you for your prompt
Thank you for your prompt answer.
The message and the snippet which I would like to use are at: drupal.org/node/337247
I am only interested in the first part "Customizing the input form":
This is what he writes:
"We want to have three kind of input elements for every biblio type: required elements, optional but visible elements, optional invisible elements (i.e. hidden in a fieldset). This can be done with biblio, but we wanted that all other fields, that we never needed, should not show up anywhere! So the "Other Biblio fields" fieldset should only contain fields that are defined for a certain type.
We did that via hook_form as follows (example for the book type): First disable *all* fields for the book type, i.e., none is required, non is visible. Then put this in yours module hook_form: [code ]
and then: "Now we put the required and optional fields into the edit form": [code]
The hidden fields go into a fieldset so that they must be uncollapsed to be viewed, just the normal "Other Biblio fields" fieldset: [code]"
I guess I didn't understand what to do and he knows...
Thanks!
Your best bet is to start
Your best bet is to start learning how to use the forms API. Here are some links to get you going:
Forms API quickstart
10-step Forms API tutorial
Forms API reference
Contact me to contract me for D7 -> D10/11 migrations.