0

in my form i have to show two radio button and one submit button,please see below my front form is like this:

candidate(radio)

organization(radio)

submit button.

my requirement is that

if user click/check on candidate radio button and click on submit then candidate form should be open on candidate page.

or

if user click/check on organization radio button and click on submit then organization form should be open on organization page.

my code:

<?php
/**@file
*donation.module*/
/**
*Implements hook_menu()*/
function donation_menu(){
$items['donate'] = array(
'title' => 'Donate',
'page callback' => 'drupal_get_form',
'page arguments' => array('donation_donate_form'),
'access arguments' => array('access content'),
'access callback' => TRUE,
);    
return $items;
}
/**
*Implements hook_form().
*/
function donation_donate_form($form, &$form_submit){
/*the options to display in our form radio buttons*/
$options = array
'candidate' => t('Candidate'),    
'organization' => t('Organization'),
);
$form['officials'] = array(    
'#title' => t('OFFICIALS'),    
'#type' => 'radios',
'#options' => $options,    
'#default_value' => $options['candidate'],
);
$form['name'] = array(
'#title' => t('NAME'),
'#type' => 'textfield',    
);
$form['submit'] = array(
'#value' => t('PROCEED'),
'#type' => 'submit',
);
return $form;
}
4
  • This question is probably better answered on the web apps page.
    – music2myear
    Oct 3, 2014 at 21:50
  • How are you displaying the form? You could just make your form redirect to the appropriate form depending on value submitted. Or you could use a multistep form as outlined in in this question: drupal.stackexchange.com/questions/17021/…
    – 2pha
    Oct 4, 2014 at 1:38
  • The examples module has an example of a mutistep form (wizard): drupal.org/project/examples
    – 2pha
    Oct 4, 2014 at 1:38
  • Thanks 2pha, i have downloaded example module and working on it. Oct 4, 2014 at 12:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.