Hi there,

Once a field has data stored in the database it is not possible to change the field length trough the administration interface. It has happened to me on multiple projects that a maximum field length that seemed to be justified in the past just didn't meet new requirements.

I used to alter these fields with a hook_update. That works for me because i know how to program in PHP. For a lot of other people i can imagine they are having more problems with this.

My module does the following:

Alter the configuration in the fields data table
Alter the configuration in the fields revision table
Alter the data column (serialized) in the field_config table

To prevent destructive actions the module does not allow lowering the maximum field length. Perhaps i will add this in the future.

I have tested this on multiple D7 sites without any issues and without data loss.

Project page : http://drupal.org/sandbox/ericmulder1980/2000476
Git repo : git clone --branch master git.drupal.org:sandbox/ericmulder1980/2000476.git field_maxlength_alter

Kind regards,
Eric Mulder

Comments

seworthi’s picture

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

An automated review of your project has found some issues with your code; As coding standards make sure projects are coded in a consistent style we please you to have a look at the report and try to fix them. Anyway, note that issues found are possibly false positives and fixing all issues is not a requirement for getting through the application process.

http://ventral.org/pareview/httpgitdrupalorgsandboxericmulder19802000476git

Please create a README.txt that follows the guidelines for in-project documentation.

The function field_maxlength_alter_form_field_ui_field_settings_form_alter() needs to be documented as a hook_form_BASE_FORM_ID_alter()

ericmulder1980’s picture

Hi Scott, thank you for your review.

  • I created a 7.x-1.x branch
  • I added a README.txt
  • I removed files[] from the .info file.
  • I added the proper documentation for the field_maxlength_alter_form_field_ui_field_settings_form_alter() function.
PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

Caseledde’s picture

Status: Needs review » Needs work

Hi,

I found some issues:

1) Use form_load_include()
Use form_load_include() to add the processing file in field_maxlength_alter_form_field_ui_field_settings_form_alter().
Do not use require in the global scope.

2) Check, if there is data
The warning message apperars always. It appears while adding a new text field also and no one can choose a value lower than 255.

That's all for now.
Happy coding

ericmulder1980’s picture

Hi Carsten, Thank you so much for your input. I fixed both issues.

1) form_load_include is now used instead of require
2) In the form_alter i now check if the field contains data before actually altering the form.

ericmulder1980’s picture

Status: Needs work » Needs review

altered a few things (#5) so back to 'needs review'

ericmulder1980’s picture

Added some small changes to fix coding standards and added field dependency.

BarisW’s picture

Status: Needs review » Reviewed & tested by the community

I've reviewed the module and all looks good. It validates Coding Standards, the t() function is used everywhere, and the code looks clean.

Thumbs up!

kscheirer’s picture

Title: [D7] field_maxlength_alter » [D7] Field Maxlength Alter
Status: Reviewed & tested by the community » Fixed

"lenght" and "lengt" should be "length". You should also remove the master branch. In field_maxlength_alter_field_ui_field_settings_form_validate() the comment doesn't match the code - is the max length 255 or 65535? Should the module be called Field Maxlength Increase? You should trim your line lengths close to 80 characters if possible, especially in the README, see http://pareview.sh/pareview/httpgitdrupalorgsandboxericmulder19802000476git.

Otherwise, I think this module is great, and should probably be in core. Not sure why we're so strict about that. Can you create an issue to add this to D9 and see what others think? Unfortunately it's too late for Drupal 8 I think.

Thanks for your contribution, ericmulder1980!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

----
Top Shelf Modules - Crafted, Curated, Contributed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Forgot to add the Git repo.