Hide a button

Hello, I have 3 entities, Account, Registration and Event. I have a button that register the $currentUser for the event he/she has selected in a templategrid. I have a working validation so that a user cannot register for the same event more than once. But, after a registration the button stays in screen with the same text 'Register!', the user will get an error that says 'already registered' if he/she presses the button. I would like to just hide the button after a registration and put the text; You have registered for this event. How can this be done? Thanks, Joey
1 answers
  1. Add an attribute to your entity - boolean, default false - 'IsRegistered';
  2. Set the 'Visibility' of the button to 'only if IsRegistered false';
  3. In the 'After commit' of the entity set IsRegistered to true;
  4. Add a row to the lay-out container that says 'Already registered', and visibility to 'on if IsRegistered true.

Also possible: don't create a boolean but an eNum attribute. Set 'empty' and 'Already registered' as eNum values.