form_state rebuild

  1. function openid_ax_persona_form(&$form_state, $persona_id = 0) {
  2.  
  3.   global $user;
  4.  
  5.   $form = array();
  6.  
  7.   $identifiers = db_query("SELECT * FROM {openid_ax_attributes}");
  8.  
  9.   $persona = db_query("SELECT * FROM {openid_ax_persona} where uid=%d", $user->uid);
  10.  
  11.   $options = array(t('Default'), 'openid_ax_create_new' =>t('Create new'));
  12.  
  13.   while($persona_value = db_fetch_array($persona)) {
  14.  
  15.         $options[$persona_value['persona_id']] = $persona_value['persona_name'];
  16.  
  17.   }
  18.  
  19.   $form['personas'] = array(
  20.  
  21.     '#type' => 'select',
  22.  
  23.     '#title' => 'Personas',
  24.  
  25.     '#options' => $options,
  26.  
  27.   );
  28.  
  29.   $form['select'] = array(
  30.  
  31.     '#type' => 'submit',
  32.  
  33.     '#value' => 'Select Persona',
  34.  
  35.     '#submit' => array('openid_ax_persona_form_submit_select_persona')
  36.  
  37.     );  
  38. return $form;
  39.  
  40. }
  41.  
  42. function openid_ax_persona_form_validate() {
  43. $form_state['rebuild'] = 'TRUE';
  44. }
  45.  
  46. function openid_ax_persona_form_submit_select_persona(&$form, $form_state) {
  47.  
  48.   global $user;
  49.  
  50.   if($form_state['values']['personas']=='openid_ax_create_new') {
  51.  
  52.         drupal_goto('user/'.$user->uid.'/persona/create');
  53.  
  54.   }
  55.  
  56.   else {
  57.  
  58.     $persona = $form_state['values']['personas'];
  59.     //$form_state['rebuild'] = 'TRUE';
  60.     return drupal_get_form('openid_ax_persona_form', &$form_state, $persona);
  61.  
  62.   }
  63.  
  64.  
  65.  
  66. }