Jump to content

Add Country Not Retourning Errors


Blesta Addons

Recommended Posts

i'm coding a new plugin , when i add a country i don't get any error if the data is invalid

for exmple a invalid fields (alpha2 /alpha3)
 

if (!empty($this->post)) {
// print_r($this->post);
// $this->Countries->add($this->post);
if (!($errors = $this->Countries->add($this->post))) {
               $this->setMessage("error", $errors, false, null, false);
               $vars = (object)$this->post;
}

$this->flashMessage("message", Language::_("AdminToolsPlugin.countries.!success", true), null, false);
$this->redirect($this->base_uri . "plugin/admin_tools/admin_countries/");
}


what wrong with this ?!

Link to comment
Share on other sites

Sorry resolved, is my fault , my eyes are closed , is 02:24 in our local time :(

 

correct code for reference

        if (!empty($this->post)) {
            $vars = (object)$this->post;

            $this->Countries->add($this->post) ;
            
            if (!($errors =  $this->Countries->errors())) {        
                $this->flashMessage("message", Language::_("AdminToolsPlugin.countries.!success", true), null, false);
                $this->redirect($this->base_uri . "plugin/admin_tools/admin_countries/add/");            
            }            
            $this->setMessage("error", $errors, false, null, false);
            $this->set("countries", $vars);
        }
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...