⚠ 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

Adding just a record



nunenthal
  • profile picture
  • Member

Posted 30 April 2021 - 16:37 PM

Hello,

 

I have a little problem, I have to add just a row in a table. 

I test if I have already a row and add

$crud->unsetAdd();

 

This work fine, but after the insert the ADD button remain visible in the datagrid, even if you try to add a second row this will create an error !

 

How I can deal with it ?

 

Thank you for your help.

 

Nunenthal Laurent

AbcWeb.lu


darkstalker
  • profile picture
  • Member

Posted 09 May 2021 - 19:32 PM

Hi !
You should left the add button visible, and then deal with the check inside the callbackBeforeInsert. If the check find a row already, you can return an error with a message saying “you can’t add a second row” or something like this.
Check the documentation about the callbackBeforeInsert to see how to deal with the error message. Of course this solution is valid if it’s ok for you to let users see the add button always. I think that would be better because the user can understand why he can’t add the row ( reading the error message ) instead of seeing the add button disappear. My two cents :)