Module entity name character limit

Created on 29 April 2020, over 4 years ago

Problem:

The Module entity names maxlength attribute is only limited to 50, which restricts writing fully even though the actual field length is 255 characters.

<input class="js-text-full text-full form-text required form-control" data-drupal-selector="edit-name-0-value" aria-describedby="edit-name-0-value--description" type="text" id="edit-name-0-value" name="name[0][value]" value="Opigno LMS, character limit of 50, instead of 255." size="255" maxlength="50" placeholder="" required="required" aria-required="true">

If we manually modify the maxlength attribute and extend the value to 255, write the title and save, we get the error

Name cannot be longer than 50 characters but is currently 51 characters long.

In the Manage Fields tab, all the fields are not available for modification.

Adjusting the textfield size in Manage Form Display doesn't also apply. We reduced it to 25, but still uses max length of 50 characters only.

Proposed Solution:

Match the Name field length to 255 in OpignoModule.php and baseFieldDefinition class and change 'max_length' attribute like other Title/Label fields

     $fields['name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Name'))
      ->setDescription(t('The name of the Module entity.'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE)
      ->setRequired(TRUE)
      ->setSettings([
        'max_length' => 255,
        'text_processing' => 0,
      ])

Workaround:

If you have already installed Opigno, applying this code above will cause an error because of the field length being out of sync now. Workaround is to run a table alter SQL query for the fields.

ALTER TABLE opigno_module_field_data MODIFY name VARCHAR(255);
ALTER TABLE opigno_module_field_revision MODIFY name VARCHAR(255);
Feature request
Status

Active

Version

2.11

Component

Code

Created by

🇵🇭Philippines eabquina Manila

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024