You are here

public function UserWishlistSettingsForm::validateForm in UC Wish List 8

Validation handler for wish list settings form.

Overrides FormBase::validateForm

File

src/Form/UserWishlistSettingsForm.php, line 169

Class

UserWishlistSettingsForm
Constructs the UserWishlistSettingsForm class.

Namespace

Drupal\uc_wishlist\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $wid = $form_state
    ->getValues('id');
  $wishlist = uc_wishlist_load($wid);
  if (!$wishlist) {
    drupal_set_message($this
      ->t('Could not find the specified wish list.'), 'error');
    return FALSE;
  }
  if ($wishlist
    ->id() != $this->account
    ->id() && !$this->account
    ->hasPermission('administer store')) {
    drupal_set_message($this
      ->t('You do not have permission to edit this wish list.'), 'error');
    return FALSE;
  }
}