1

I hate the title to my question but this is basically what is happening. WSOD is killing me and I can not figure this one out.

Basically what i am doing is attempting to have any user navigate to a url that would build a form, submit it and generate a graph.

for example

http://server/data-points/bade/bcharts/datacenter=rr&device=pdu total&startdate=2012-09-26 10:43&enddate=2012-09-27 10:43

so from the second menu path below in the hooks_menu() function, this should call bcharts_directBuild() with all the data after /data-points/bade/bcharts/%. bcharts_directBuild is calling drupal_form_submit but seems to WSOD every time. watchdog is not giving me anything and all erroring is enabled. Is there something I'm missing here?

I would also like to point out that datacenter_devices is dependent on which datacenter you are selecting. so there is an ajax call in there. and also bcharts_directBuild has been hard coded just for testing purposes.

Here is my code

function bcharts_menu() {

$items['data-points/bade/bcharts'] = array(
        'title'             => 'Data Charts',
        'page callback'     => 'bcharts_page',
        'access arguments'  => array('access content'),
        'file'              => 'bade_charts.inc',
);


$items['data-points/bade/bcharts/%'] = array(
        'page callback'     => 'bcharts_directBuild',
        'page arguments'    => array(3),
        'access arguments'  => array('access content'),
        'file'              => 'bade_charts.inc',
);

return $items;
}

function bcharts_form($form, &$form_state) {

global $dcEquipment; 

$datacenterOptions = _bcharts_datacenterOptions($dcEquipment);

isset($form_state['values']['datacenter']) ?
    $datacenterSelect = $form_state['values']['datacenter'] : $datacenterSelect = 'Ridge Rd';

isset($form_state['values']['datacenter_devices']) ?
    $DCDeviceSelect = $form_state['values']['datacenter_devices'] : $DCDeviceSelect = '';

// Calculate the start date for default value
isset($form_state['values']['start_date']) ?
    $currentDate = $form_state['values']['start_date'] : $currentDate = date("Y-m-d H:i:s");

// Calculate the end date for default value. This is plus one day.
isset($form_state['values']['end_date']) ?
    $lastdayDate = $form_state['values']['end_date'] :  $lastdayDate = date("Y-m-d H:i:s", time(date("Y-m-d H:i:s")) - 86400);


// Start Date for the form
$form['start_date'] = array(
    '#type'             => 'date_popup',
    '#title'            => 'Start Date',
    '#date_format'      => 'Y-m-d H:i',
    '#date_increment'   => 1,
    '#date_year_range'  => '-2:0',
    '#default_value'    => $lastdayDate,
    '#required'         => TRUE,
);

// End Date for the form
$form['end_date'] = array(
    '#type'             => 'date_popup',
    '#title'            => 'End Date',
    '#date_format'      => 'Y-m-d H:i',
    '#date_increment'   => 1,
    '#date_year_range'  => '-2:0',
    '#default_value'    => $currentDate,
    '#required'         => TRUE,
);


// Datacenter drop down
$form['datacenter'] = array(
    '#type'             => 'select',
    '#title'            => 'Datacenter',
    '#options'          => $datacenterOptions,                      
    '#default_value'    => $datacenterSelect,                               
    '#required'         => TRUE,
    '#ajax'             => array(
            'callback'  => '_bcharts_equipmentCallback',
            'wrapper'   => 'datacenter-devices',
    ),
);

$form['datacenter_devices'] = array(
    '#type'             => 'select',
    '#title'            => $datacenterSelect. ' ' .t('Datacenter Devices'),
    '#prefix'           => '<div id="datacenter-devices">',
    '#suffix'           => '</div>',
    '#required'         => TRUE,
    '#options'          => _bcharts_getDatacenterDevices($dcEquipment, $datacenterSelect),
    '#default_value'    => $DCDeviceSelect,
);

// Normal Submit button
$form['submit'] = array(
    '#type'     => 'submit',
    '#value'    => t('Display'),
);

$form['results'] = array(
    '#type'     => 'item',
    '#markup'   => '<div id="chartdiv" style="width:100%; height:400px;"></div>',
);

return $form;
}

function bcharts_directBuild($args = '') {

$form_state = array();

$form_state['values']['datacenter']             = 'rr';
$form_state['values']['datacenter_devices']     = 'ups total';
$form_state['values']['start_date']             = '2012-09-26 10:43'; 
$form_state['values']['end_date']               = '2012-09-27 10:43';
$form_state['values']['op']                     = t('Display');

drupal_form_submit('bcharts_form', $form_state);

$errors = form_get_errors();
if (!empty($errors)) {
    foreach ($errors as $error) {
        $msg = 'Error: %error';
        $var = array('%error' => $error);
        watchdog('bcharts', $msg, $var, WATCHDOG_ERROR);
    }
}

}
4
  • What is the error in the Apache logs?
    – mpdonadio
    Sep 27, 2012 at 17:21
  • nothing in the logs
    – au_stan
    Sep 27, 2012 at 17:30
  • It appears that your url is somewhat malformed, eg, you don't start off your query variables/arguments with a ?= but jump right in with an =. Could this be squirreling things up even before it gets to drupal?
    – Jimajamma
    Sep 27, 2012 at 18:48
  • i doubt it. regardless if i've gotten the url to be acceptable or not, how would you handle this? if i do something like http://server/data-points/bade/bcharts?datacenter=rr&device=pdu total&startdate=2012-09-26 10:43&enddate=2012-09-27 10:43 the path is not actually picked up.
    – au_stan
    Sep 27, 2012 at 18:55

0

Your Answer

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

Browse other questions tagged or ask your own question.