本文整理汇总了PHP中Drupal\Core\Form\ConfigFormBase::validateForm方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFormBase::validateForm方法的具体用法?PHP ConfigFormBase::validateForm怎么用?PHP ConfigFormBase::validateForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\ConfigFormBase
的用法示例。
在下文中一共展示了ConfigFormBase::validateForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
parent::validateForm($form, $form_state);
if (empty($form['#translation_directory']) && $form_state->getValue('use_source') == LOCALE_TRANSLATION_USE_SOURCE_LOCAL) {
$form_state->setErrorByName('use_source', $this->t('You have selected local translation source, but no <a href=":url">Interface translation directory</a> was configured.', array(':url' => $this->url('system.file_system_settings'))));
}
}
示例2: validateForm
/**
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
$error = array();
$sf_library = preg_replace("/(^[\r\n]*|[\r\n]+)[\\s\t]*[\r\n]+/", "\n", trim($form_state->getValue('superfish_library')));
if (empty($sf_library)) {
$form_state->setErrorByName('superfish_library', t('Path to Superfish library field cannot be empty. Please try this list:') . str_replace("\r\n", ",", $this->superfish_library_path()));
} else {
// Trimming blank lines and such
$sf_library = explode("\n", $sf_library);
// Crystal clear
foreach ($sf_library as $s) {
if (!file_exists($s)) {
$error[] = $s;
}
}
if (!empty($error)) {
$error_message = '';
if (count($error) > 1) {
foreach ($error as $e) {
$error_message .= '<li>' . $e . '</li>';
}
$error_message = t('Files not found') . ': <ul>' . $error_message . '</ul>';
} else {
$error_message = t('File not found') . ': ' . $error[0];
}
$form_state->setErrorByName('superfish_library', $error_message);
}
}
parent::validateForm($form, $form_state);
}
示例3: validateForm
/**
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validateForm(array &$form, array &$form_state)
{
$form_state['notify_emails'] = array();
if (!empty($form_state['values']['update_notify_emails'])) {
$valid = array();
$invalid = array();
foreach (explode("\n", trim($form_state['values']['update_notify_emails'])) as $email) {
$email = trim($email);
if (!empty($email)) {
if (valid_email_address($email)) {
$valid[] = $email;
} else {
$invalid[] = $email;
}
}
}
if (empty($invalid)) {
$form_state['notify_emails'] = $valid;
} elseif (count($invalid) == 1) {
$this->setFormError('update_notify_emails', $form_state, $this->t('%email is not a valid email address.', array('%email' => reset($invalid))));
} else {
$this->setFormError('update_notify_emails', $form_state, $this->t('%emails are not valid email addresses.', array('%emails' => implode(', ', $invalid))));
}
}
parent::validateForm($form, $form_state);
}
示例4: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state)
{
parent::validateForm($form, $form_state);
if (!intval($form_state['values']['request_token_lifetime'], 10)) {
form_set_error('oauth_request_token_lifetime', t('The request token lifetime must be a non-zero integer value.'));
}
}
示例5: validateForm
/**
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validateForm(array &$form, array &$form_state)
{
parent::validateForm($form, $form_state);
if (empty($form['#translation_directory']) && $form_state['values']['use_source'] == LOCALE_TRANSLATION_USE_SOURCE_LOCAL) {
$this->setFormError('use_source', $form_state, $this->t('You have selected local translation source, but no <a href="@url">Interface translation directory</a> was configured.', array('@url' => url('admin/config/media/file-system'))));
}
}
示例6: validateForm
/**
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
$form_state->set('notify_emails', []);
if (!$form_state->isValueEmpty('update_notify_emails')) {
$valid = array();
$invalid = array();
foreach (explode("\n", trim($form_state->getValue('update_notify_emails'))) as $email) {
$email = trim($email);
if (!empty($email)) {
if (valid_email_address($email)) {
$valid[] = $email;
} else {
$invalid[] = $email;
}
}
}
if (empty($invalid)) {
$form_state->set('notify_emails', $valid);
} elseif (count($invalid) == 1) {
$form_state->setErrorByName('update_notify_emails', $this->t('%email is not a valid email address.', array('%email' => reset($invalid))));
} else {
$form_state->setErrorByName('update_notify_emails', $this->t('%emails are not valid email addresses.', array('%emails' => implode(', ', $invalid))));
}
}
parent::validateForm($form, $form_state);
}
示例7: validateForm
/**
* {@inheritdoc}
*
* @DCG: Optional.
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
if ($form_state->getValue('example') != 'example') {
$form_state->setErrorByName('example', $this->t('The value is not correct.'));
}
parent::validateForm($form, $form_state);
}
示例8: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
parent::validateForm($form, $form_state);
if ($form_state->getValue('usar-fecha-prueba-cron') && !$form_state->getValue('fecha-prueba-cron')) {
$form_state->setErrorByName('fecha-prueba-cron', "Se requiere una fecha si se activa la opcion de prueba para CRON");
}
}
示例9: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
parent::validateForm($form, $form_state);
if (!intval($form_state->getValue('request_token_lifetime', 10))) {
$form_state->setErrorByName('oauth_request_token_lifetime', $this->t('The request token lifetime must be a non-zero integer value.'));
}
}
示例10: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
parent::validateForm($form, $form_state);
// Call the form validation handler for each of the toolkits.
foreach ($this->availableToolkits as $toolkit) {
$toolkit->validateConfigurationForm($form, $form_state);
}
}
示例11: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
parent::validateForm($form, $form_state);
$tabindex = $form_state->getValue('recaptcha_tabindex');
if (!is_numeric($tabindex)) {
$form_state->setErrorByName('recaptcha_tabindex', t('The tabindex must be an integer.'));
}
}
示例12: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
$default_format = trim($form_state->getValue(['name_settings', 'default_format']));
if (empty($default_format) && !strlen($default_format)) {
$form_state->setErrorByName('name_settings][default_format', t('%title field is required.', array('%title' => $form['name_settings']['default_format']['#title'])));
}
parent::validateForm($form, $form_state);
}
示例13: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
parent::validateForm($form, $form_state);
$form_state->setValue('container_id', trim($form_state->getValue('container_id')));
if (!preg_match('/^GTM-.*$/', $form_state->getValue('container_id'))) {
$form_state->setErrorByName('container_id', t('A valid Google Tag Manager Container ID is case sensitive and formatted like GTM-XXXXXX.'));
}
}
示例14: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, array &$form_state)
{
$child_type = $form_state['values']['book_child_type'];
if (empty($form_state['values']['book_allowed_types'][$child_type])) {
$this->setFormError('book_child_type', $form_state, $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => $this->t('Add child page'))));
}
parent::validateForm($form, $form_state);
}
示例15: validateForm
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state)
{
$child_type = $form_state->getValue('book_child_type');
if ($form_state->isValueEmpty(array('book_allowed_types', $child_type))) {
$form_state->setErrorByName('book_child_type', $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => $this->t('Add child page'))));
}
parent::validateForm($form, $form_state);
}