开发者

Why is my form not updating as it should?

The submit handler gets the same form values no matter what I put in the form. Why???????

function edit_schoolinfo_form() {
    global $user;
    $result = db_query("SELECT * FROM {db} where userid=%d", $user->uid);
    $sas_school_info = db_fetch_array($result);
    $form = array();
    $form['school'] = array('#type' => 'fieldset', '#title' => t('School Information'), '#weight' => - 17,);
    $form['school']['principlename'] = array('#type' => 'textfield', '#title' => t('Principle Name '), '#required' => TRUE, '#size' => 45, '#weight' => - 11, '#value' => $sas_school_info['principlename'],);
    $form['school']['schoolname'] = array('#type' => 'textfield', '#title' => t('School Name '), '#required' => TRUE, '#size' => 45, '#weight' => - 10,'#value' => $sas_school_info['schoolname'],);
    $form['school']['address1'] = array('#type' => 'textfield', '#title' => t('Address 1'), '#required' => TRUE, '#size' => 45, '#weight' => - 9.1,'#value' => $sas_school_info['address1'],);
    $form['school']['address2'] = array('#type' => 'textfield', '#title' => t('Address 2'), '#required' => FALSE, '#size' => 45, '#weight' => - 9,'#value' => $sas_school_info['address2'],);
    $form['school']['city'] = array('#type' => 'textfield', '#title' => t('City'), '#required' => TRUE, '#size' => 30, '#weight' => - 12, '#weight' => - 5.2,'#value' => $sas_school_info['city'],);

    $form['school']['state'] = array('#type' => 'select', '#options' => greenopolis_sasapp_states_list(), '#title' => t('State'), '#required' => TRUE, '#weight' => - 5.0,'#default_value'=>$sas_school_info['state'],);
    $form['school']['zipcode'] = array('#type' => 'textfield', '#title' => t('School Zip Code'), '#required' => TRUE, '#size' => 20, '#weight' => - 4.9,'#value' => $sas_school_info['zipcode'],);
    $form['school']['terminalid'] = array('#type' => 'hidden', '#title' => t('Terminal ID'), '#required' => TRUE, '#size' => 20, '#weight' => - 4.8, '#value' => $terminalid, '#disabled' => TRUE);


    $form['admin'] = array('#type' => 'fieldset', '#title' => t('School Administrator Contact Information'), '#weight' => - 16,);
    $form['admin']['adminfname'] = array('#type' => 'textfield', '#title' => t('Administrator First Name'), '#required' => TRUE, '#size' => 45,'#value' => $sas_school_info['admin_first_name'],);
    //   $form['account']['mail'] = array('#type' => 'textfield', '#title' => t('Administrator Email'), '#required' => TRUE, '#size' => 45,);
    $form['admin']['adminlname'] = array('#type' => 'textfield', '#title' => t('Administrator Last Name'), '#required' => TRUE, '#size' => 45,'#value' => $sas_school_info['admin_last_name'],);
    $form['admin']['phoneno'] = array('#type' => 'textfield', '#title' => t('Phone Number'), '#required' => TRUE, '#size' => 45,'#value' => $sas_school_info['admin_phone'],);
    //  $form['account']['name'] = array('#type' => 'textfield', '#title' => t('Username'), '#required' => TRUE, '#size' => 45,);
    // $form['account']['pass'] = array('#type' => 'password_confirm', '#size' => 25, '#description' => t(''), '#required' => TRUE);


    $form['submit'] = array('#type' => 'submit', '#value' => t('Save Information'));

    return $form;


} //end of the function



function edit_schoolinfo_form_submit($form_id, &$form_state) {


    $principlename = $form_state['values']['principlename开发者_高级运维'];
    $schoolname = $form_state['values']['schoolname'];
    $address1 = $form_state['values']['address1'];
    $address2 = $form_state['values']['address2'];
    $city = $form_state['values']['city'];
    $state = $form_state['values']['state'];
    $zipcode = $form_state['values']['zipcode'];
    $admin_first_name = $form_state['values']['adminfname'];
    $admin_last_name = $form_state['values']['adminlname'];
    $admin_email = $form_state['values']['mail'];
    $admin_phone = $form_state['values']['phoneno'];



}


Use #default_value to set the stored values from the database, instead of #value. When you set #value, that will be the value regardless of what the user submits.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜