⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Showing an error message before the callback functions



Akhilkalapurakkal
  • profile picture
  • Member

Posted 27 September 2018 - 07:30 AM

Hi Everyone,

 

I just need a help to show an error message if the callbackBeforeUpdate function returns FALSE.

 

Thanks


larasmith
  • profile picture
  • Member

Posted 01 October 2018 - 00:29 AM

        $crud->callbackBeforeUpdate(function ($stateParameters) {
           $this->load->model('m_Section');

           $section = $this->m_Section->checkExistingSubSection($stateParameters->data['subsect_Section'], $stateParameters->data['subsect_Name'], $stateParameters->primaryKeyValue);

           if($section == 1){

              return (new \GroceryCrud\Core\Error\ErrorMessage())->setMessage("<h3>The subsection already exists!</h3>");
           }
           else{
              return $stateParameters;
           }
        }); 

The sample above checks if a record exists, if it does it will return an error message.

 

Hope it helps! Cheers!  :lol:


Akhilkalapurakkal
  • profile picture
  • Member

Posted 01 October 2018 - 07:29 AM

Thanks @Larasmith. It's working now. Thank you very much.


larasmith
  • profile picture
  • Member

Posted 04 October 2018 - 03:56 AM

Thanks @Larasmith. It's working now. Thank you very much.

 

Glad to help!  :)