• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exiting Controller

#1
[eluser]spider pig[/eluser]
I have created a form and my controller script validates it and builds an error message in the variable $errorMessage. I then test if $errorMessage is not NULL, I display the form again with an error box. I then want to exit the script:
Code:
// header displayed earlier in code
if ($errorMessage != NULL) {
    $row->al_error_message = $this->error->error_box($errorMessage);
    $this->load->view('newsletter_form', $row);
    $this->load->view('footer', $settings);
    exit;
}

However, nothing displays. Is there a way to output what is already passed to output before I exit?

Thanks

#2
[eluser]Jilani Jidni[/eluser]
[quote author="Dale Rodgie" date="1220356597"]I have created a form and my controller script validates it and builds an error message in the variable $errorMessage. I then test if $errorMessage is not NULL, I display the form again with an error box. I then want to exit the script:
Code:
// header displayed earlier in code
if ($errorMessage != NULL) {
    $row->al_error_message = $this->error->error_box($errorMessage);
    $this->load->view('newsletter_form', $row);
    $this->load->view('footer', $settings);
    exit;
}

However, nothing displays. Is there a way to output what is already passed to output before I exit?

Thanks[/quote]

Your code does not seems any problem. are you sure your program enter into the if condition. if yes then check this function
Code:
$this->error->error_box($errorMessage);
. and also debug your code......

#3
[eluser]Mark van der Walle[/eluser]
Since a while exiting in controllers might not show any output (due to partial view support). The best (and also cleanest way) is:
Code:
// header displayed earlier in code
if ($errorMessage != NULL) {
    $row->al_error_message = $this->error->error_box($errorMessage);
    $this->load->view('newsletter_form', $row);
    $this->load->view('footer', $settings);
    return;
}

#4
[eluser]spider pig[/eluser]
Thanks Mark. It works a treat.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.