Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- An AJAX HTTP error occurred.
- HTTP Result Code: 500
- Debugging information follows.
- Path: /drupal/?q=system/ajax
- StatusText: Service unavailable (with message)
- ResponseText: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ajax' in 'where clause': SELECT district_name, country_id,state_id FROM {ajax_district} where id = ajax; Array
- (
- )
- in edit_district_form() (line 291 of /home/mansmu/www/drupal/sites/default/modules/ajaxtest/ajaxtest.district.inc).
- ////////////////////////////////////////////////////////
- ///////// FUNCTION FOR EDIT
- ////////////////////////////////////////////////////////
- function edit_district_form($form, &$form_state) {
- $request_url = request_uri();
- // $request_id to get id of edit district.
- $request_id = drupal_substr(strrchr($request_url, '/'), 1);
- //// FOR country
- $rows = array();
- $result = db_query("SELECT id,country_name from {ajax_country} order by country_name");
- while ($data = $result->fetchObject()) {
- $id = $data->id;
- $rows[$id] = $data->country_name;
- }
- //// FOR state
- $state = array();
- $result = db_query("SELECT id,state_name from {ajax_state} order by state_name");
- while ($data = $result->fetchObject()) {
- $id = $data->id;
- $state[$id] = $data->state_name;
- }
- // $district_name varible to get name from database for a requested id.
- $district_name = db_query("SELECT district_name, country_id,state_id FROM {ajax_district} where id = ".$request_id);
- // Loop For show vehicle district name in text field to be update.
- foreach ($district_name as $district) {*/
- $form['values']['edit_country_name'] = array(
- '#type' => 'select',
- // '#default_value' => "{$district->country_id}",
- '#required' => TRUE,
- '#options' => $rows,
- '#ajax' => array(
- 'effect' => 'fade',
- 'progress' => array('type' => 'none'),
- 'callback' => 'state_callback_edit',
- 'wrapper' => 'replace_edit_state',
- ),
- );
- $form['values']['edit_state_name'] = array(
- '#type' => 'select',
- // '#default_value' => "{$district->state_id}",
- '#required' => TRUE,
- '#options' => array(),
- // The prefix/suffix provide the div that we're replacing, named by #ajax['wrapper'] above.
- '#prefix' => '',
- '#suffix' => '',
- );
- $form['values']['edit_district_name'] = array(
- '#type' => 'textfield',
- '#size' => 30,
- //'#default_value' => "{$district->district_name}",
- '#maxlength' => 80,
- '#required' => TRUE,
- );
- }
- $form['edit_district_submit'] = array(
- '#type' => 'submit',
- '#value' => t('Update'),
- );
- $form['actions']['cancel'] = array(
- '#markup' => l(t('Cancel'), 'district'),
- );
- return $form;
- }
- ////////////////////////////////////////////////////////
- ///////// FUNCTION FOR AJAX CALL BACK
- ////////////////////////////////////////////////////////
- function state_callback_edit($form, &$form_state) {
- // An AJAX request calls the form builder function for every change.
- // We can change how we build the form based on $form_state.
- if (!empty($form_state['values']['edit_country_name'])) {
- $country_id = $form_state['values']['edit_country_name'];
- $rows1 = array();
- $result = db_query("SELECT id, state_name from {ajax_state} where country_id = $country_id order by state_name");
- while ($data = $result->fetchObject()) {
- $id = $data->id;
- $rows1[$id] = $data->state_name;
- }
- $form['edit_state_name']['#options'] = $rows1;
- }
- return $form['values']['edit_state_name'];
- }
- SELECT district_name, country_id,state_id FROM {ajax_district} where id = ajax;
- $form['request_id'] = array('#type' => 'value', '#value' => $request_id);
Advertisement
Add Comment
Please, Sign In to add comment