With THEME_form_system_site_information_settings_alter i can change the max field length of the site_slogan form, like:

function THEME_form_system_site_information_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['site_information']['site_slogan']['#maxlength'] = 500;
}

Apparently the form for the slogan in the site information translation is different,

thus forexample in /admin/config/system/site-information/translate/en/edit

There is other form for the slogan.

Did a lot of grep in the core code, but could n't find it, anyone knows how to change it or where this form is?

Thanks

Nico

Comments

wombatbuddy’s picture

Try this: 

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter().
 */
function YOUR_MODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'system_site_information_settings') {
    $form['site_information']['site_slogan']['#type'] = 'textarea';
    $form['site_information']['site_slogan']['#maxlength'] = 500;
  }
  elseif ($form_id == 'config_translation_edit_form') {
    $form['config_names']['system.site']['slogan']['translation']['#type'] = 'textarea';
    $form['config_names']['system.site']['slogan']['translation']['#maxlength'] = 500;
  }
}
ulterius’s picture

It is working!,

coming from d6/7 and now d8/9 it's a steep hill. But slowly i'm coming to the end.

Thanks,

NIco

Anybody’s picture

I ran into a similar issue at https://www.drupal.org/project/cookies/issues/3327045 today and wrote a blog post with a snippet:

https://julian.pustkuchen.com/en/remove-config-translation-textfield-max...

Here's our hook_preprocess_HOOK to solve it:

/**
 * Implements hook_preprocess_HOOK().
 */
function cookies_preprocess_config_translation_manage_form_element(&$variables) {
  // Temporary fix for: https://www.drupal.org/project/cookies/issues/3327045
  // Drupal limits config translation textfields (string) to a maxlength of 128.
  // In our forms we set #maxlength to a higher limit so we need to remove
  // the limit also for the config translation forms:
  // Only for textfields:
  if (!empty($variables['element']['translation']['#type']) && $variables['element']['translation']['#type'] == 'textfield') {
    // Only for items starting with 'source[config_names][cookies.',
    // so we don't affect other items.
    if (strpos($variables['element']['source']['#name'], 'source[config_names][cookies.') === 0) {
      // Remove the #maxlength limit entirely. There's no technical limit.
      unset($variables['element']['translation']['#maxlength']);
    }
  }
}

http://www.DROWL.de || Professionelle Drupal Lösungen aus Ostwestfalen-Lippe (OWL)
http://www.webks.de || webks: websolutions kept simple - Webbasierte Lösungen die einfach überzeugen!
http://www.drupal-theming.com || Individuelle Responsive Themes