Loading src/Form/RegistrationForm.php +9 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,15 @@ class RegistrationForm extends ContentEntityForm { $form = parent::buildForm($form, $form_state); $form_state->set('registration', $this->entity); // Prevent edits to fields on locked registrations. if ($this->entity->locked->value) { foreach (array_keys($this->entity->getFields()) as $field_name) { if (isset($form[$field_name]) && $field_name !== 'locked') { $form[$field_name]['#disabled'] = TRUE; } } } // Change the 'Save' submit button label. $form['actions']['submit']['#value'] = $this->entity->isNew() ? $this->t('Register') : $this->t('Update Registration'); Loading src/ParticipantAccessControlHandler.php +10 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,16 @@ class ParticipantAccessControlHandler extends EntityAccessControlHandler { case 'view': case 'update': case 'delete': // Participants of locked registrations can't be edited or deleted. if ($operation === 'update' || $operation === 'delete') { /** @var \Drupal\erf\Entity\RegistrationInterface $registration */ foreach ($entity->getRegistrations() as $registration) { if ($registration->locked->value) { return AccessResult::forbidden('Deletion or editing not allowed when registration is locked.'); } } } if ($this->ownsRegistration($entity, $account)) { return AccessResult::allowedIfHasPermission($account, 'manage own registrations'); } Loading Loading
src/Form/RegistrationForm.php +9 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,15 @@ class RegistrationForm extends ContentEntityForm { $form = parent::buildForm($form, $form_state); $form_state->set('registration', $this->entity); // Prevent edits to fields on locked registrations. if ($this->entity->locked->value) { foreach (array_keys($this->entity->getFields()) as $field_name) { if (isset($form[$field_name]) && $field_name !== 'locked') { $form[$field_name]['#disabled'] = TRUE; } } } // Change the 'Save' submit button label. $form['actions']['submit']['#value'] = $this->entity->isNew() ? $this->t('Register') : $this->t('Update Registration'); Loading
src/ParticipantAccessControlHandler.php +10 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,16 @@ class ParticipantAccessControlHandler extends EntityAccessControlHandler { case 'view': case 'update': case 'delete': // Participants of locked registrations can't be edited or deleted. if ($operation === 'update' || $operation === 'delete') { /** @var \Drupal\erf\Entity\RegistrationInterface $registration */ foreach ($entity->getRegistrations() as $registration) { if ($registration->locked->value) { return AccessResult::forbidden('Deletion or editing not allowed when registration is locked.'); } } } if ($this->ownsRegistration($entity, $account)) { return AccessResult::allowedIfHasPermission($account, 'manage own registrations'); } Loading