liamrichards
asked on
Adding a form module to a specific page
Ok, so I need to add a custom form to my user profile page in Drupal. I.e. the /user/1/edit/ form.
I don't want to just alter the existing form because I need it to have a different submission actions.
So I'm going to create a custom module for the form. This is an example I have found on the internet:
This is all well and good, but this just adds the form to the menu, and puts it on its own page. How could I get this form inserted into a particular area on my User Profile page?
I don't want to use the webforms module or anything, just want a custom form module inserted on my page.
Thanks,
I don't want to just alter the existing form because I need it to have a different submission actions.
So I'm going to create a custom module for the form. This is an example I have found on the internet:
<?php
function example_help($section) {
switch ($section) {
case 'admin/modules#description':
return t('This module implements an example form.');
}
}
function example_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'example',
'title' => t('Example'),
'callback' => 'example_page',
'access' => TRUE,
'type' => MENU_CALLBACK
);
}
return $items;
}
function example_page() {
return drupal_get_form('example_page_form');
}
function example_page_form() {
$form['fullname'] = array(
'#type' => 'textfield',
'#title' => t('Enter your full name'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
function example_page_form_submit($form_id, $form_values) {
$message = 'You have submitted the ' . $form_id . ' form which contains the following data:<pre>' . print_r($form_values,true) . '</pre>';
drupal_set_message(t($message));
}
?>
This is all well and good, but this just adds the form to the menu, and puts it on its own page. How could I get this form inserted into a particular area on my User Profile page?
I don't want to use the webforms module or anything, just want a custom form module inserted on my page.
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.