Posted by viral007in on March 28, 2011 at 8:30am
Hi All
I need an help for custom form.
I have created a form, but after submit the form does not show $form_state and values of the fields.
function redeempoints_user_add_form(&$form_state)
{
$form = array();
$form['point_user'] = array(
'#type' => 'textfield',
'#title' => t('User Name'),
'#size' => 30,
'#maxlength' => 60,
'#required' => TRUE,
'#default_value' => '',
'#autocomplete_path' => 'user/autocomplete',
'#description' => t('User Name for the user you want the !points to affect'),
);
$form['client_id'] = array(
'#type' => 'textfield',
'#title' => t('Client ID'),
'#size' => 30,
'#maxlength' => 60,
'#required' => TRUE,
'#default_value' => '',
'#description' => t('Client ID for the user you want the !points to affect'),
);
$form['current_point'] = array(
'#type' => 'textfield',
'#title' => t('Current Points'),
'#size' => 10,
'#maxlength' => 10,
'#disable' => TRUE,
);
$form['buttons'] = array(
'save_button' => array(
'#type' => 'submit',
'#value' => t('save'),
'#validate' => array('redeempoints_user_add_form_validate_save'),
'#submit' => array('redeempoints_user_add_form_submit_save'),
),
);
return $form;
}
function redeempoints_user_add_form_validate_save($form, &$form_state)
{
$values = $form_state['values'];
$storage = $form_state['storage'];
print_r($values);
}
function redeempoints_user_add_form_submit_save($form, &$form_state)
{
$values = $form_state['values'];
$storage = $form_state['storage'];
print_r($values);
drupal_set_message(t('Form submitted'));
//$form_state['redirect'] = 'admin/user/redeempoints/thankyou';
}
Please help
Warm Regards
Viral

Comments
Check you menu, that should
Check you menu, that should be look like this following
$items['yourmenu'] = array(
'title' => t('title page'),
'page callback' => 'drupal_get_form',
'page arguments' => array('submittofunction'),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
check your menu have "drupal_get_form"
hope this will work.
No it did not solve the
No it did not solve the issue.
$items['admin/user/redeempoints'] = array(
'title' => 'Redeem Points',
'access arguments' => array(USERPOINTS_PERM_ADMIN),
'page callback' => 'hello_world',
'type' => MENU_NORMAL_ITEM,
);
I have defined the MENU as Local task, seem thing is missing
multi step form
I think you want multistep form functionality
The following code will help you
function redeempoints_user_add_form($form,&$form_state)
}
function redeempoints_user_add_form_submit($form,&$form_state)
$form_state['rebuild'] = TRUE;
$form_state['storage']['values'] = $form_state['values'];
//put code here
}
if you want single step
function redeempoints_user_add_form()
}
function redeempoints_user_add_form_submit($form,&$form_state)
//print_r($form_state);
}
Thanks naushunaushad
I am not creating Multi Step form, but a Add/Edit/Delete/List Form, each form have certain different function in it.
Any way your suggestion worked.
Warm Regards
*_*
Instead of
<?php$form['buttons'] = array(
'save_button' => array(
'#type' => 'submit',
'#value' => t('save'),
'#validate' => array('redeempoints_user_add_form_validate_save'),
'#submit' => array('redeempoints_user_add_form_submit_save'),
),
);
?>
I'm not sure if
'save_button' => array()exisit in Drupal form API.Try this
<?php$form['#validate'] = array('redeempoints_user_add_form_validate_save');
$form['#submit'] = array('redeempoints_user_add_form_submit_save');
?>
BeautifulMind