Hi everyone
I have installed the Event Manager module which is working awesome and covers about 80% of my requirements for a few of my clients.
Two clients in particular asked if they could have extra and different fields when a user registers.
For example:
A extra field to see if the person is bringing a partner to the event.
Extra: Contact Number fields.
etc.
So I was thinking I should could modify the existing Event Manager module or should I could write a new module which depends on the event manager module and somehow overides the function that displays the registration form.
The second option sounds easier for me to maintain and this way I can keep my modifications in my seperate module.
How would I go about doing something like this? Is there a standard way in drupal to overide a function in another module?
Regards Julian
Comments
if you just need an extended
[edit]my answer was to fast, sorry. i thought you are using the event module where my answer is regarded to.[/edit]
if you just need an extended event node you can use
------------------------------------------------------
Remember: I compute you!
I am using the event module
I am using the event module and event_manager modules.
The event_manager module allows you to register for a event. It provides a default form which asks for...
First Name
Last Name
Email
Email Confirmation
Phone
I need to add extra fields to this page. I would love to add the aditional fields with cck but I can only add those fields to the content type itself and not to the registration page.
I hope I am making more sense here...
So if there is a standard way which I can override a the function which generates the registration form for the event. It would be quite helpfull.
I'm still reading through the API section in hopes of getting a answer to my problem.
Some pointers
Yes modules can do all that stuff quite easily without any need to edit anybody elses code (once you know how).
A module can use hook_form_alter() to alter any existing form in Drupal. Forms are a nested PHP array defined by the Form API.
hook_nodeapi() can be used by a module to hook into any operations on a node defined by another module. eg if you have added extra fields to a node edit form with your modules form_alter hook, your modules nodeapi hook can be used to save and/or operate on the data from those extra fields.
Here is an example module:
http://api.drupal.org/api/file/developer/examples/nodeapi_example.module...
--
Anton
Thank you Anton
This is exactly what I'm looking for :)
nodeapi and register_event form
So I got to the point where I could add extra fields to the event_registration form using hook_form_alter.
The form that event_manager module displays is not a typical node created by a content type. It is created and displayed by the event_manager module's "event_manager_registration_form" function.
So I used "hook_form_alter" like this:
Where I used the function name that displays the event_manager registration form as the form_id.
Now it seems that I cant really use "hook_nodeapi" to insert the aditional fields into the database.
I'm not sure if I'm missing something but it looks like "hook_nodeapi" doesn't work with forms that is created from modules.
Is there another way I could access this "data/extra fields" and insert it into the database?
OK, I didn't realise you weren't dealing with nodes
Yeah, hook_nodeapi is only for catching node operations.
Another approach...
Your form_alter hook can alter what happens when the form is submitted:
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html... (it's a bit cleaner in Drupal 6)
You can add your own submit handler (ie a function in your module) into the array. eg your new handler would process the fields you added to the form.
You can also add your own validation functions too.
--
Anton