Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Custom error message #406

Open
Francesco-1277 opened this issue May 17, 2017 · 0 comments
Open

Custom error message #406

Francesco-1277 opened this issue May 17, 2017 · 0 comments

Comments

@Francesco-1277
Copy link

Francesco-1277 commented May 17, 2017

hi,

I want to implement a custom error message, my question is very similar to this #145 except for the fact that I need an additional layer of validation even when the normal validation rules are respected.

At the moment I solved in this way

`$form->saved(function () use ($form) {
    $get_record = DB::table('my_table')->where('fk_key_1', $form->model->fk_key_1)->
    where('fk_key_2', $form->model->fk_key_2)->where('type', $form->model->type)->first();

    if ($get_record->id) {
      $form->message("There is another record with the same properties, so the record was not saved.");
      $cancella = DB::table('my_table')->where('id', $form->model->id)->delete();
      $form->link("/my_controller/edit?modify=" . $get_record->id, "Edit the existing record");
    } else {
      $form->message("Record saved");
      $form->link("/my_controller/edit?modify=" . $form->model->id,"Edit the record");
    }
  });`

but it's not so elegant, nor efficient, to delete a record after the insertion. Do you have any suggestions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant