⚠ 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 forum is read-only and soon will be archived. ⚠


Adding just a record


  • Please log in to reply
1 reply to this topic

#1 nunenthal

nunenthal

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 30 April 2021 - 04: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



#2 darkstalker

darkstalker

    Member

  • Members
  • PipPip
  • 26 posts

Posted 09 May 2021 - 07: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 :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users