本文整理汇总了PHP中Drupal\Core\Form\ConfigFormBase::buildForm方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFormBase::buildForm方法的具体用法?PHP ConfigFormBase::buildForm怎么用?PHP ConfigFormBase::buildForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\ConfigFormBase
的用法示例。
在下文中一共展示了ConfigFormBase::buildForm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$cart_config = $this->config('uc_cart.settings');
$form['cart-settings'] = array('#type' => 'vertical_tabs', '#attached' => array('library' => array('uc_cart/uc_cart.admin.scripts')));
$form['general'] = array('#type' => 'details', '#title' => t('Basic settings'), '#group' => 'cart-settings');
$form['general']['uc_cart_add_item_msg'] = array('#type' => 'checkbox', '#title' => t('Display a message when a customer adds an item to their cart.'), '#default_value' => $cart_config->get('add_item_msg'));
$form['general']['uc_add_item_redirect'] = array('#type' => 'textfield', '#title' => t('Add to cart redirect'), '#description' => t('Enter the page to redirect to when a customer adds an item to their cart, or <none> for no redirect.'), '#default_value' => $cart_config->get('add_item_redirect'), '#size' => 32, '#field_prefix' => $this->url('<front>', [], ['absolute' => TRUE]));
$form['general']['uc_cart_empty_button'] = array('#type' => 'checkbox', '#title' => t('Show an "Empty cart" button on the cart page.'), '#default_value' => $cart_config->get('empty_button'));
$form['general']['uc_minimum_subtotal'] = array('#type' => 'uc_price', '#title' => t('Minimum order subtotal'), '#description' => t('Customers will not be allowed to check out if the subtotal of items in their cart is less than this amount.'), '#default_value' => $cart_config->get('minimum_subtotal'));
$form['lifetime'] = array('#type' => 'details', '#title' => t('Cart lifetime'), '#description' => t('Set the length of time that products remain in the cart. Cron must be running for this feature to work.'), '#group' => 'cart-settings');
$range = range(1, 60);
$form['lifetime']['anonymous'] = array('#type' => 'fieldset', '#title' => t('Anonymous users'), '#attributes' => array('class' => array('uc-inline-form', 'clearfix')));
$form['lifetime']['anonymous']['uc_cart_anon_duration'] = array('#type' => 'select', '#title' => t('Duration'), '#options' => array_combine($range, $range), '#default_value' => $cart_config->get('anon_duration'));
$form['lifetime']['anonymous']['uc_cart_anon_unit'] = array('#type' => 'select', '#title' => t('Units'), '#options' => array('minutes' => t('Minute(s)'), 'hours' => t('Hour(s)'), 'days' => t('Day(s)'), 'weeks' => t('Week(s)'), 'years' => t('Year(s)')), '#default_value' => $cart_config->get('anon_unit'));
$form['lifetime']['authenticated'] = array('#type' => 'fieldset', '#title' => t('Authenticated users'), '#attributes' => array('class' => array('uc-inline-form', 'clearfix')));
$form['lifetime']['authenticated']['uc_cart_auth_duration'] = array('#type' => 'select', '#title' => t('Duration'), '#options' => array_combine($range, $range), '#default_value' => $cart_config->get('auth_duration'));
$form['lifetime']['authenticated']['uc_cart_auth_unit'] = array('#type' => 'select', '#title' => t('Units'), '#options' => array('hours' => t('Hour(s)'), 'days' => t('Day(s)'), 'weeks' => t('Week(s)'), 'years' => t('Year(s)')), '#default_value' => $cart_config->get('auth_unit'));
$form['continue_shopping'] = array('#type' => 'details', '#title' => t('Continue shopping element'), '#description' => t('These settings control the <em>continue shopping</em> option on the cart page.'), '#group' => 'cart-settings');
$form['continue_shopping']['uc_continue_shopping_type'] = array('#type' => 'radios', '#title' => t('<em>Continue shopping</em> element'), '#options' => array('link' => t('Text link'), 'button' => t('Button'), 'none' => t('Do not display')), '#default_value' => $cart_config->get('continue_shopping_type'));
$form['continue_shopping']['uc_continue_shopping_use_last_url'] = array('#type' => 'checkbox', '#title' => t('Make <em>continue shopping</em> go back to the last item that was added to the cart.'), '#description' => t('If this is disabled or the item is unavailable, the URL specified below will be used.'), '#default_value' => $cart_config->get('continue_shopping_use_last_url'));
$form['continue_shopping']['uc_continue_shopping_url'] = array('#type' => 'textfield', '#title' => t('Default <em>continue shopping</em> destination'), '#default_value' => $cart_config->get('continue_shopping_url'), '#size' => 32, '#field_prefix' => $this->url('<front>', [], ['absolute' => TRUE]));
$form['breadcrumb'] = array('#type' => 'details', '#title' => t('Cart breadcrumb'), '#description' => t('Drupal automatically adds a <em>Home</em> breadcrumb to the cart page, or you can use these settings to specify a custom breadcrumb.'), '#group' => 'cart-settings');
$form['breadcrumb']['uc_cart_breadcrumb_text'] = array('#type' => 'textfield', '#title' => t('Cart page breadcrumb text'), '#description' => t('Leave blank to use the default <em>Home</em> breadcrumb.'), '#default_value' => $cart_config->get('breadcrumb_text'));
$form['breadcrumb']['uc_cart_breadcrumb_url'] = array('#type' => 'textfield', '#title' => t('Cart page breadcrumb destination'), '#default_value' => $cart_config->get('breadcrumb_url'), '#size' => 32, '#field_prefix' => $this->url('<front>', [], ['absolute' => TRUE]));
return parent::buildForm($form, $form_state);
}
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
{
$config = $this->config('easychart.settings');
$load_defaults = FALSE;
// Get defaults.
foreach ($this->getDefaults() as $default) {
// Verify default options.
$default_value = $config->get($default);
if (empty($default_value)) {
// Set flag to true.
$load_defaults = TRUE;
$form['#attached']['drupalSettings']['easychart'][$default] = TRUE;
}
}
if ($load_defaults) {
$form['#attached']['library'][] = 'easychart/easychart.defaults';
$form['#attached']['library'][] = 'easychart/lib.easycharts.full';
}
$options = $config->get('options');
$form['options'] = ['#type' => 'textarea', '#title' => $this->t('Available options'), '#description' => $this->t('These Highcharts options will be configurable in the Easychart interface when creating/editing a chart. See <a href="@url" target="_blank">http://api.highcharts.com/highcharts</a> for all available options.', array('@url' => Url::fromUri('http://api.highcharts.com/highcharts')->toUriString())), '#default_value' => $options, '#attributes' => array('class' => array('easychart-options')), '#rows' => 15];
$form['templates'] = ['#type' => 'textarea', '#title' => t('Available templates'), '#default_value' => $config->get('templates'), '#description' => t("These templates will be selectable in the Easychart interface when creating/editing a chart."), '#attributes' => array('class' => array('easychart-templates')), '#rows' => 15];
$form['presets'] = ['#type' => 'textarea', '#title' => t('Presets'), '#default_value' => $config->get('presets'), '#description' => $this->t('Presets for every Easychart chart. If these preset are also mentioned in the available options, they will be shown, but not editable.'), '#attributes' => array('class' => array('easychart-presets')), '#rows' => 10];
$interval = array(3600, 10800, 21600, 32400, 43200, 86400, 172800);
$form['url_update_frequency'] = ['#type' => 'select', '#title' => t('Update frequency'), '#options' => array(0 => t('Never')) + array_map([\Drupal::service('date.formatter'), 'formatInterval'], array_combine($interval, $interval)), '#default_value' => $config->get('url_update_frequency'), '#description' => $this->t('When to update the data for charts using a CSV URL.'), '#rows' => 10];
$form['actions']['reset'] = ['#type' => 'submit', '#value' => t('Reset to defaults'), '#submit' => array('::resetForm'), '#limit_validation_errors' => array(), '#weight' => 100];
return parent::buildForm($form, $form_state);
}
示例3: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form = parent::buildForm($form, $form_state);
$config = $this->config('rules_test_ui_embed.settings');
$form['css_file'] = ['#type' => 'textfield', '#title' => $this->t('CSS file'), '#default_value' => $config->get('css.0.file'), '#required' => TRUE];
return $form;
}
示例4: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('system.maintenance');
$form['maintenance_mode'] = array('#type' => 'checkbox', '#title' => t('Put site into maintenance mode'), '#default_value' => $this->state->get('system.maintenance_mode'), '#description' => t('Visitors will only see the maintenance mode message. Only users with the "Access site in maintenance mode" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array(':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login'))));
$form['maintenance_mode_message'] = array('#type' => 'textarea', '#title' => t('Message to display when in maintenance mode'), '#default_value' => $config->get('message'));
return parent::buildForm($form, $form_state);
}
示例5: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('c4a_connect.fbconnectadmin_config');
$form['application_id'] = array('#type' => 'textfield', '#title' => $this->t('Application ID'), '#description' => $this->t('Also called the <em>OAuth client_id</em> value on Facebook App settings pages. <a href="https://www.facebook.com/developers/createapp.php">Facebook Apps must first be created</a> before they can be added here'), '#default_value' => $config->get('application_id'));
$form['application_secret'] = array('#type' => 'textfield', '#title' => $this->t('Application secret'), '#description' => $this->t('Also called the <em>OAuth client_secret</em> value on Facebook App settings pages.'), '#default_value' => $config->get('application_secret'));
return parent::buildForm($form, $form_state);
}
示例6: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('event_dispatcher_demo.demo_form_config');
$form['my_name'] = ['#type' => 'textfield', '#title' => $this->t('My name'), '#default_value' => $config->get('my_name')];
$form['my_website'] = ['#type' => 'textfield', '#title' => $this->t('My website'), '#default_value' => $config->get('my_website')];
return parent::buildForm($form, $form_state);
}
示例7: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('mymodules.mysettings_config');
$form['nom'] = array('#type' => 'textfield', '#title' => $this->t('nom'), '#description' => $this->t('tapez votre nom'), '#default_value' => $config->get('nom'));
$form['pr_nom'] = array('#type' => 'textfield', '#title' => $this->t('prénom'), '#description' => $this->t(''), '#default_value' => $config->get('pr_nom'));
return parent::buildForm($form, $form_state);
}
示例8: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form = array();
// Initialize a language list to the ones available, including English.
$languages = $this->languageManager->getLanguages();
$existing_languages = array();
foreach ($languages as $langcode => $language) {
$existing_languages[$langcode] = $language->getName();
}
// If we have no languages available, present the list of predefined languages
// only. If we do have already added languages, set up two option groups with
// the list of existing and then predefined languages.
if (empty($existing_languages)) {
$language_options = $this->languageManager->getStandardLanguageListWithoutConfigured();
} else {
$language_options = array($this->t('Existing languages') => $existing_languages, $this->t('Languages not yet added') => $this->languageManager->getStandardLanguageListWithoutConfigured());
}
$form['mappings'] = array('#tree' => TRUE, '#theme' => 'language_negotiation_configure_browser_form_table');
$mappings = $this->language_get_browser_drupal_langcode_mappings();
foreach ($mappings as $browser_langcode => $drupal_langcode) {
$form['mappings'][$browser_langcode] = array('browser_langcode' => array('#title' => $this->t('Browser language code'), '#title_display' => 'invisible', '#type' => 'textfield', '#default_value' => $browser_langcode, '#size' => 20, '#required' => TRUE), 'drupal_langcode' => array('#title' => $this->t('Site language'), '#title_display' => 'invisible', '#type' => 'select', '#options' => $language_options, '#default_value' => $drupal_langcode, '#required' => TRUE));
}
// Add empty row.
$form['new_mapping'] = array('#type' => 'details', '#title' => $this->t('Add a new mapping'), '#tree' => TRUE);
$form['new_mapping']['browser_langcode'] = array('#type' => 'textfield', '#title' => $this->t('Browser language code'), '#description' => $this->t('Use language codes as <a href="@w3ctags">defined by the W3C</a> for interoperability. <em>Examples: "en", "en-gb" and "zh-hant".</em>', array('@w3ctags' => 'http://www.w3.org/International/articles/language-tags/')), '#size' => 20);
$form['new_mapping']['drupal_langcode'] = array('#type' => 'select', '#title' => $this->t('Site language'), '#options' => $language_options);
return parent::buildForm($form, $form_state);
}
示例9: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('google_site_search.settings');
$form['google_site_search_key'] = ['#type' => 'textfield', '#title' => $this->t('Google site search key'), '#description' => $this->t('Google Site Search Key'), '#maxlength' => 64, '#size' => 64, '#default_value' => $config->get('google_site_search_key')];
$form['google_site_search_index'] = ['#type' => 'textfield', '#title' => $this->t('Google Site Search Index'), '#description' => $this->t('Google Site Search Index'), '#maxlength' => 64, '#size' => 64, '#default_value' => $config->get('google_site_search_index')];
return parent::buildForm($form, $form_state);
}
示例10: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('better_formats.settings');
$form['control'] = ['#type' => 'fieldset', '#title' => t('Control')];
$form['control']['per_field_core'] = ['#type' => 'checkbox', '#title' => t('Use field default'), '#description' => t('Use the core field module default value to set the default format. This will force the default format even when the default field value is empty. To set a default format you must re-edit a text field after saving it with the "Filtered text" option turned on.'), '#default_value' => $config->get('per_field_core')];
return parent::buildForm($form, $form_state);
}
示例11: buildForm
/**
* Form constructor.
*
* @param array $form
* An associative array containing the structure of the form.
* @param array $form_state
* An associative array containing the current state of the form.
*
* @return array
* The form structure.
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
global $base_url;
$config = $this->config('login_security.settings');
$form['track_time'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Track time'), '#default_value' => $config->get('track_time'), '#size' => 3, '#description' => $this->t('The time window to check for security violations: the time in hours the login information is kept to compute the login attempts count. A common example could be 24 hours. After that time, the attempt is deleted from the list, and will never be considered again.'), '#field_suffix' => $this->t('Hours'));
$form['user_wrong_count'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Maximum number of login failures before blocking a user'), '#default_value' => $config->get('user_wrong_count'), '#size' => 3, '#description' => $this->t('Enter the number of login failures a user is allowed. After this amount is reached, the user will be blocked, no matter the host attempting to log in. Use this option carefully on public sites, as an attacker may block your site users. The user blocking protection will not disappear and should be removed manually from the <a href=":user">user management</a> interface.', array(':user' => $base_url . '/admin/people')), '#field_suffix' => $this->t('Failed attempts'));
$form['host_wrong_count'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Maximum number of login failures before soft blocking a host'), '#default_value' => $config->get('host_wrong_count'), '#size' => 3, '#description' => $this->t('Enter the number of login failures a host is allowed. After this amount is reached, the host will not be able to submit the log in form again, but can still browse the site contents as an anonymous user. This protection is effective during the time indicated at tracking time option.'), '#field_suffix' => $this->t('Failed attempts'));
$form['host_wrong_count_hard'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Maximum number of login failures before blocking a host'), '#default_value' => $config->get('host_wrong_count_hard'), '#size' => 3, '#description' => $this->t('Enter the number of login failures a host is allowed. After this number is reached, the host will be blocked, no matter the username attempting to log in. The host blocking protection will not disappear automatically and should be removed manually from the <a href=":access">access rules</a> administration interface.', array(':access' => $base_url . '/admin/config/people/ban')), '#field_suffix' => $this->t('Failed attempts'));
$form['activity_threshold'] = array('#type' => 'number', '#min' => 0, '#title' => $this->t('Maximum number of login failures before detecting an ongoing attack'), '#default_value' => $config->get('activity_threshold'), '#size' => 3, '#description' => $this->t('Enter the number of login failures before creating a warning log entry about this suspicious activity. If the number of invalid login events currently being tracked reach this number, and ongoing attack is detected.'), '#field_suffix' => $this->t('Failed attempts'));
$form['login_messages'] = array('#type' => 'fieldset', '#title' => $this->t('Notifications'));
$form['login_messages']['disable_core_login_error'] = array('#type' => 'checkbox', '#title' => $this->t('Disable login failure error message'), '#description' => $this->t('Checking this option prevents the display of login error messages. A user attempting to login will not be aware if the account exists, an invalid user name or password has been submitted, or if the account is blocked. The core messages "Unrecognized username or password. Have you forgotten your password?" and "The username {username} has not been activated or is blocked." are also hidden.'), '#default_value' => $config->get('disable_core_login_error'));
$form['login_messages']['notice_attempts_available'] = array('#type' => 'checkbox', '#title' => $this->t('Notify the user about the number of remaining login attempts'), '#default_value' => $config->get('notice_attempts_available'), '#description' => $this->t('Checking this option, the user is notified about the number of remaining login attempts before the account gets blocked. Security tip: If you enable this option, try to not disclose as much of your login policies as possible in the message shown on any failed login attempt.'));
$form['login_messages']['last_login_timestamp'] = array('#type' => 'checkbox', '#title' => $this->t('Display last login timestamp'), '#description' => $this->t('Checking this option, when a user successfully logs in, a message will display the last time he logged into the site.'), '#default_value' => $config->get('last_login_timestamp'));
$form['login_messages']['last_access_timestamp'] = array('#type' => 'checkbox', '#title' => $this->t('Display last access timestamp'), '#description' => $this->t('Checking this option, when a user successfully logs in, a message will display the last site access with this account.'), '#default_value' => $config->get('last_access_timestamp'));
$form['login_messages']['user_blocked_email_user'] = array('#type' => 'textfield', '#title' => $this->t('Select who should get an email message when a user is blocked by this module'), '#description' => $this->t('No notification will be sent if the field is blank'), '#default_value' => $config->get('user_blocked_email_user'), '#autocomplete_path' => 'user/autocomplete', '#element_validate' => array(array(get_class($this), 'validUser')));
$form['login_messages']['login_activity_email_user'] = array('#type' => 'textfield', '#title' => $this->t('Select who should get an email message when an ongoing attack is detected'), '#description' => $this->t('No notification will be sent if the field is blank'), '#default_value' => $config->get('login_activity_email_user'), '#autocomplete_path' => 'user/autocomplete', '#element_validate' => array(array(get_class($this), 'validUser')));
$form['login_security']['Notifications'] = array('#type' => 'fieldset', '#title' => $this->t('Edit notification texts'), '#weight' => 3, '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t("You may edit the notifications used by the Login Security module. Allowed placeholders for all the notifications include the following: <ul><li>%date : The (formatted) date and time of the event.</li><li>%ip : The IP address tracked for this event.</li><li>%username : The username entered in the login form (sanitized).</li><li>%email : If the user exists, this will be the email address.</li><li>%uid : If the user exists, this will be the user uid.</li><li>%site : The name of the site as configured in the administration.</li><li>%uri : The base url of this Drupal site.</li><li>%edit_uri : Direct link to the user (based on the name entered) edit page.</li><li>%hard_block_attempts : Configured maximum attempts before hard blocking the IP address.</li><li>%soft_block_attempts : Configured maximum attempts before soft blocking the IP address.</li><li>%user_block_attempts : Configured maximum login attempts before blocking the user.</li><li>%user_ip_current_count : The total attempts for this user name tracked from this IP address.</li><li>%ip_current_count : The total login attempts tracked from from this IP address.</li><li>%user_current_count : The total login attempts tracked for this user name .</li><li>%tracking_time : The tracking time value: in hours.</li><li>%tracking_current_count: Total tracked events</li><li>%activity_threshold : Value of attempts to detect ongoing attack.</li></ul>"));
$form['login_security']['Notifications']['notice_attempts_message'] = array('#type' => 'textarea', '#title' => $this->t('Message to be shown on each failed login attempt'), '#rows' => 2, '#default_value' => $config->get('notice_attempts_message'), '#description' => $this->t('Enter the message string to be shown if the login fails after the form is submitted. You can use any of the placeholders here.'));
$form['login_security']['Notifications']['host_soft_banned'] = array('#type' => 'textarea', '#title' => $this->t('Message for banned host (Soft IP ban)'), '#rows' => 2, '#default_value' => $config->get('host_soft_banned'), '#description' => $this->t('Enter the soft IP ban message to be shown when a host attempts to log in too many times.'));
$form['login_security']['Notifications']['host_hard_banned'] = array('#type' => 'textarea', '#rows' => 2, '#title' => $this->t('Message for banned host (Hard IP ban)'), '#default_value' => $config->get('host_hard_banned'), '#description' => $this->t('Enter the hard IP ban message to be shown when a host attempts to log in too many times.'));
$form['login_security']['Notifications']['user_blocked'] = array('#type' => 'textarea', '#rows' => 2, '#title' => $this->t('Message when user is blocked by uid'), '#default_value' => $config->get('user_blocked'), '#description' => $this->t('Enter the message to be shown when a user gets blocked due to enough failed login attempts.'));
$form['login_security']['Notifications']['user_block_email'] = array('#type' => 'fieldset', '#title' => $this->t('Email to be sent to the defined user for blocked accounts.'), '#weight' => 3, '#description' => $this->t('Configure the subject and body of the email message.'));
$form['login_security']['Notifications']['user_block_email']['user_blocked_email_subject'] = array('#type' => 'textfield', '#title' => $this->t('Email subject'), '#default_value' => $config->get('user_blocked_email_subject'));
$form['login_security']['Notifications']['user_block_email']['user_blocked_email_body'] = array('#type' => 'textarea', '#title' => $this->t('Email body'), '#default_value' => $config->get('user_blocked_email_body'), '#description' => $this->t('Enter the message to be sent to the administrator informing a user has been blocked.'));
$form['login_security']['Notifications']['login_activity_email'] = array('#type' => 'fieldset', '#title' => $this->t('Email to be sent to the defined user for ongoing attack detections.'), '#weight' => 3, '#description' => $this->t('Configure the subject and body of the email message.'));
$form['login_security']['Notifications']['login_activity_email']['login_activity_email_subject'] = array('#type' => 'textfield', '#title' => $this->t('Email subject'), '#default_value' => $config->get('login_activity_email_subject'));
$form['login_security']['Notifications']['login_activity_email']['login_activity_email_body'] = array('#type' => 'textarea', '#title' => $this->t('Email body'), '#default_value' => $config->get('login_activity_email_body'), '#description' => $this->t('Enter the message to be sent to the administrator informing about supicious activity.'));
// Clean event tracking list.
$form['buttons']['clean_tracked_events'] = array('#type' => 'submit', '#value' => $this->t('Clear event tracking information'), '#weight' => 20, '#submit' => array('::clean_tracked_events'));
return parent::buildForm($form, $form_state);
}
示例12: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL)
{
MollomUtilities::displayMollomTestModeWarning();
$config = $this->config('mollom.settings');
// Only check and display the status message if the form is being shown
// for the first time and not when displayed again after submission.
$check = empty($_POST);
if ($check) {
$status = MollomUtilities::getAdminAPIKeyStatus($check);
if ($status['isVerified'] && !$config->get('test_mode.enabled')) {
drupal_set_message(t('Mollom servers verified your keys. The services are operating correctly.'));
}
}
$form['keys'] = array('#type' => 'details', '#title' => t('Mollom API keys'), '#tree' => TRUE, '#description' => t('To obtain API keys, <a href="@signup-url">sign up</a> or log in to your <a href="@site-manager-url">Site manager</a>, register this site, and copy the keys into the fields below.', array('@signup-url' => 'https://mollom.com/pricing', '@site-manager-url' => 'https://mollom.com/site-manager')), '#open' => isset($status) ? !$status['isVerified'] : true);
// Keys are not #required to allow to install this module and configure it
// later.
$form['keys']['public'] = array('#type' => 'textfield', '#title' => t('Public key'), '#default_value' => $config->get('keys.public'), '#description' => t('Used to uniquely identify this site.'));
$form['keys']['private'] = array('#type' => 'textfield', '#title' => t('Private key'), '#default_value' => $config->get('keys.private'), '#description' => t('Used for authentication. Similar to a password, the private key should not be shared with anyone.'));
$form['fallback'] = array('#type' => 'radios', '#title' => t('When the Mollom service is unavailable'), '#default_value' => $config->get('fallback'), '#options' => array(Settings::MOLLOM_FALLBACK_ACCEPT => t('Accept all form submissions'), Settings::MOLLOM_FALLBACK_BLOCK => t('Block all form submissions')), '#description' => t('Mollom offers a <a href="@pricing-url">high-availability</a> infrastructure for users on paid plans to reduce potential downtime.', array('@pricing-url' => 'https://mollom.com/pricing')));
$options = DrupalClient::getSupportedLanguages();
$default_languages = !empty($status['expectedLanguages']) ? $status['expectedLanguages'] : $config->get("languages_expected");
// @todo: Add chosen UI functionality for improved UX when available.
$form['languages_expected'] = array('#type' => 'select', '#title' => t('Expected languages'), '#options' => $options, '#multiple' => TRUE, '#size' => 6, '#default_value' => $default_languages, '#description' => t('Restricts all posts to selected languages. Used by text analysis only. Leave empty if users may post in other languages.'));
$form['privacy_link'] = array('#type' => 'checkbox', '#title' => t("Show a link to Mollom's privacy policy"), '#return_value' => true, '#default_value' => $config->get('privacy_link'), '#description' => t('Only applies to forms protected with text analysis. When disabling this option, you should inform visitors about the privacy of their data through other means.'));
$form['testing_mode'] = array('#type' => 'checkbox', '#title' => t('Enable testing mode'), '#return_value' => true, '#default_value' => $config->get('test_mode.enabled'), '#description' => t('Submitting "ham", "unsure", or "spam" triggers the corresponding behavior; image CAPTCHAs only respond to "correct" and audio CAPTCHAs only respond to "demo". Do not enable this option if this site is publicly accessible.'));
$form['advanced'] = array('#type' => 'details', '#title' => t('Advanced configuration'), '#open' => FALSE);
// Lower severity numbers indicate a high severity level.
$form['advanced']['log_level'] = array('#type' => 'radios', '#title' => t('Mollom logging level warning'), '#options' => array(RfcLogLevel::WARNING => t('Only log warnings and errors'), RfcLogLevel::DEBUG => t('Log all Mollom messages')), '#default_value' => $config->get('log_level'));
$form['advanced']['audio_captcha_enabled'] = array('#type' => 'checkbox', '#title' => t('Enable audio CAPTCHAs.'), '#description' => t('Allows users to switch to an audio verification using the <a href="!faq-url">NATO alphabet</a>. This may not be appropriate for non-English language sites.', array('!faq-url' => 'https://mollom.com/faq/mollom-audible-captcha-language')), '#return_value' => true, '#default_value' => $config->get('captcha.audio.enabled'));
$timeout = $config->get('connection_timeout_seconds');
$form['advanced']['connection_timeout_seconds'] = array('#type' => 'number', '#title' => t('Time-out when attempting to contact Mollom servers.'), '#description' => t('This is the length of time that a call to Mollom will wait before timing out.'), '#default_value' => !empty($timeout) ? $config->get('connection_timeout_seconds') : 3, '#size' => 5, '#field_suffix' => t('seconds'), '#required' => TRUE);
return parent::buildForm($form, $form_state);
}
示例13: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$form = parent::buildForm($form, $form_state);
$config = $this->config('encrypt.settings');
$form['check_profile_status'] = array('#type' => 'checkbox', '#title' => $this->t('Show the validation status of encryption profiles.'), '#description' => $this->t('On the encryption profiles overview page, automatically validate each encryption profile to check if there are problems with it. Disable when you have a lot of encryption profiles and are encountering performance issues, or if you do not want encryption keys to be loaded by the status check.'), '#default_value' => $config->get('check_profile_status'));
return $form;
}
示例14: buildForm
public function buildForm(array $form, FormStateInterface $form_state)
{
$system_roles = user_roles($membersonly = TRUE);
$config = \Drupal::config('registration_role_with_approval.settings');
$site_config = \Drupal::configFactory()->get('system.mail');
$mailing_list = $config->get('mailing_list');
if ($mailing_list == "") {
$mailing_list .= $site_config->get('mail');
}
$email_subject = $config->get('email_subject');
$email_body = $config->get('email_body');
$profile_roles = $config->get('profile_roles');
$form['roles'] = array('#type' => 'fieldset', '#title' => t('Avaliable Roles on registration form'), '#collapsible' => TRUE);
foreach ($system_roles as $system_role) {
$role_id = $system_role->id();
if ($role_id != '0' && $role_id != 'authenticated') {
$form['roles'][$system_role->id()] = array('#type' => 'checkbox', '#title' => t($system_role->label()), '#default_value' => $profile_roles[$system_role->id()]['default']);
$form['roles'][$system_role->id() . "needs_approval"] = array('#type' => 'checkbox', '#title' => t('needs approval'), '#states' => array('invisible' => array(":input[name='{$role_id}']" => array('checked' => FALSE))), '#attributes' => array('style' => 'margin-left: 2em'), '#default_value' => $profile_roles[$system_role->id()]['needs_approval']);
}
}
$form['custom_mail'] = array('#type' => 'fieldset', '#title' => t('Custom registration email configuration'), '#collapsible' => TRUE);
$form['custom_mail']['new_email'] = array("#type" => "textfield", "#title" => "Enter valid email");
$form['custom_mail']['add_email'] = array("#type" => "button", "#value" => "Add email", "#ajax" => array('callback' => 'Drupal\\registration_role_with_approval\\Form\\RegistrationRoleWithApprovalSettingsForm::addEmailCallback', 'event' => 'click', 'effect' => 'fade', 'progress' => array('type' => 'throbber')));
$form['custom_mail']['mailing_list'] = array("#type" => "textarea", "#title" => "Mailing list", "#default_value" => $mailing_list);
$form['custom_mail']['email_subject'] = array("#type" => "textfield", "#title" => "Email subject", "#default_value" => $email_subject);
$form['custom_mail']['email_body'] = array("#type" => "textarea", "#title" => "Email body", "#default_value" => $email_body);
return parent::buildForm($form, $form_state);
}
示例15: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$config = $this->config('swaps.swapsettings_config');
$form['enable_bootstrap'] = array('#type' => 'checkbox', '#title' => $this->t('Enable Bootstrap'), '#description' => $this->t(''), '#default_value' => $config->get('enable_bootstrap'));
$form['enable_fontawesome'] = array('#type' => 'checkbox', '#title' => $this->t('Enable FontAwesome'), '#description' => $this->t(''), '#default_value' => $config->get('enable_fontawesome'));
return parent::buildForm($form, $form_state);
}