I'm programming an EE extension, and in the save_settings()
method, if I redirect()
(after unsuccessful data validation), the message stored in the set_flashdata()
method doesn't show.
If I comment the redirect and let the method put the user back in the main extensions page, then the flashdata shows up fine. It's only if I redirect that the data isn't shown.
This is my save settings method - as near as I can tell I'm not doing anything out of the ordinary - it's mostly boilerplate as near as I can tell. I'd be very appreciative of anybody that can shed light on this...
function save_settings(){
// no unauthorized access
if (empty($_POST)) {
show_error($this->EE->lang->line('unauthorized_access'));
}
// get the routestring then convert it to an array
$routestring = $this->EE->security->xss_clean($this->EE->input->post('routes'));
$results = $this->routes_to_array($routestring);
// if the conversion was ok:
if ($results['status'] == 'success') {
// update db
$this->EE->db->where('class', __CLASS__);
$this->EE->db->update('extensions', array('settings' => serialize(array('routes' => $results['results']))));
// set flash data
$this->EE->session->set_flashdata('message_success', "Routes updated.");
// if something went wrong during conversion:
} else {
// set flash data then redirect back to edit screen
$this->EE->session->set_flashdata('message_failure', $results['message']);
// IF I COMMENT THE FOLLOWING LINE, THE FLASH DATA SHOWS UP FINE
$this->EE->functions->redirect(BASE.AMP.'C=addons_extensions'.AMP.'M=extension_settings'.AMP.'file=apsdsm_bossyboots');
}
}
OK, this is my view file - as far as I can tell this is as boiler plate as it gets. More boiler plate than a dish that's been held in scalding water for ten minutes.
<?php echo form_open('C=addons_extensions'.AMP.'M=save_extension_settings'.AMP.'file=apsdsm_bossyboots'); ?>
<table class="mainTable" border="0"cellspacing="0" cellpadding="0">
<thead>
<tr>
<th>
Routes
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<?php echo form_textarea(array('name'=>'routes', 'value' => $routestring)) ?>
<?php echo form_submit('submit', 'Update Routes', 'class="submit"') ?>
</td>
</tr>
</tbody>
</table>
<?php echo form_close()?>
ext_flash
cookie is being set correctly - I can see the correct error data being passed along in the headers, but it's not displaying...ext_flash
, I meantexp_flash
.