本文整理匯總了PHP中Drupal\Core\Form\ConfirmFormBase::validateForm方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConfirmFormBase::validateForm方法的具體用法?PHP ConfirmFormBase::validateForm怎麽用?PHP ConfirmFormBase::validateForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Form\ConfirmFormBase
的用法示例。
在下文中一共展示了ConfirmFormBase::validateForm方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
parent::validateForm($form, $form_state);
// Only authenticated users can leave a collection.
/** @var \Drupal\user\UserInterface $user */
$user = User::load($this->currentUser()->id());
if ($user->isAnonymous()) {
$form_state->setErrorByName('user', $this->t('<a href=":login">Log in</a> or <a href=":register">register</a> to change your group membership.', [':login' => Url::fromRoute('user.login'), ':register' => Url::fromRoute('user.register')]));
}
// Check if the user is a member of the collection.
if (!Og::isMember($this->collection, $user)) {
$form_state->setErrorByName('collection', $this->t('You are not a member of this collection. You cannot leave it.'));
}
}
示例2: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
parent::validateForm($form, $form_state);
}