You are here

remove_field_label_length_limit.module in Remove field label length limit 7

File

remove_field_label_length_limit.module
View source
<?php

/**
 * Implements hook_form_FORM_ID_alter().
 */
function remove_field_label_length_limit_form_field_ui_field_overview_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['fields']['_add_new_field']['label'])) {
    $form['fields']['_add_new_field']['label']['#maxlength'] = 1024;
  }
  if (isset($form['fields']['_add_existing_field']['label'])) {
    $form['fields']['_add_existing_field']['label']['#maxlength'] = 1024;
  }
  if (isset($form['fields']['_add_new_group']['label'])) {
    $form['fields']['_add_new_group']['label']['#maxlength'] = 1024;
  }
  if (!empty($form['#groups'])) {
    foreach ($form['#groups'] as $group_name) {
      if (isset($form['fields'][$group_name]['format']['format_settings']['settings']['label'])) {
        $form['fields'][$group_name]['format']['format_settings']['settings']['label']['#maxlength'] = 1024;
      }
    }
  }
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function remove_field_label_length_limit_form_field_ui_display_overview_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['fields']['_add_new_group']['label'])) {
    $form['fields']['_add_new_group']['label']['#maxlength'] = 1024;
  }
  if (!empty($form['#groups'])) {
    foreach ($form['#groups'] as $group_name) {
      if (isset($form['fields'][$group_name]['format']['format_settings']['settings']['label'])) {
        $form['fields'][$group_name]['format']['format_settings']['settings']['label']['#maxlength'] = 1024;
      }
    }
  }
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function remove_field_label_length_limit_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['instance']['label'])) {
    $form['instance']['label']['#maxlength'] = 1024;
  }
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function remove_field_label_length_limit_form_views_ui_config_item_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['options']['label'])) {
    $form['options']['label']['#maxlength'] = 1024;
  }
}

/**
 * Implements hook_module_implements_alter().
 */
function remove_field_label_length_limit_module_implements_alter(&$implementations, $hook) {
  if ($hook !== 'form_alter') {
    return;
  }
  if (!isset($implementations['remove_field_label_length_limit'])) {
    return;
  }
  $implementation = $implementations['remove_field_label_length_limit'];
  unset($implementations['remove_field_label_length_limit']);
  $implementations['remove_field_label_length_limit'] = $implementation;
}