hook_form_alter
is a drupal API function. You can google "hook_form_alter" and the 1st result will be the API documentation for this function; it includes examples.
Using this "hook" function you can inject, or otherwise change, any form in your drupal website. A "form" is an HTML construct that can send data to a webserver via either POST or GET.
So, you can create a custom drupal Module (which consist of in this case an .info
file and a .module
file). In your module you can create a function that implements "hook_form_alter" and adds in the zendesk field.
A simple simple example of this would be:
# in the below examples lets assume you have named your module folder as "zext" (kinda short for zendesk extensions .... i dunno :P
# in zext.info
name = Custom Zendesk Form Extensions
descrption = We want to add custom fields to the zendesk form.
package = Other
core = 7.x
# in zext.module
<?php
/**
* Implements hook_form_alter().
*
* Alter the zendesk form and add a custom color text field.
*/
function zext_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'zendesk_form') {
$form['zendesk_favorite_color'] = array(
'#type' => 'textfield',
'#title' => t('Favorite Color'),
'#description' => t('Please tell us what your favorite color is!'),
'#weight' => 99,
);
}
}
# that is all the code that would be in the 2 files.
With the above 2 small pieces of code we have modified the default zendesk_form (I assume its $form_id
is zendesk_form
... it may be different examine the module's code to see how it IDs the forms ...) and added 1 single new custom field to allow the visitor to submit their favorite color. Drupal doesn't store these values anywhere -- they are just passed onto Zendesk upon form submission; You simply need to create the folder + 2 files and install the module in the drupal administration. Your module folder should be called zext
.
There is alot of documentation online for creating modules, and using hook_form_alter. Look on drupal.org and Google.
Happy Coding!