Attached is a patch that trims generated text to a fields maximum length value, if set.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

awolfey’s picture

Patch attached.

moshe weitzman’s picture

i think this is a dupe - can't search right now

awolfey’s picture

I found a couple of issues on length of titles. This patch affects textareas only.

awolfey’s picture

Needed to cast the length as an integer to prevent warnings.

awolfey’s picture

Adds another needed check.

salvis’s picture

Status: Active » Needs review
salvis’s picture

Makes sense, except for the trailing spaces here:

+++ b/devel_generate/devel_generate.inc
@@ -504,6 +504,10 @@ function devel_create_content($type = NULL) {
+    $output = substr($output, 0, (int) $field['settings']['max_length']);    ¶

It still applies, too.

@moshe: I see two related issues:
#689212: provide option for limiting number of chars of generated body text (old feature request for D6)
#1010394: Use devel_create_greeking for text field instead of user_password (feature request for text fields, not text areas)

Neither of these are exact duplicates.

LGLC’s picture

Issue tags: +LONDON_2013_APRIL

As far as I can tell, textareas now don't have a maximum length (only a number of rows for display purposes). There is no max_length in field_settings. It seems that this issue therefore doesn't exist any more.

pcambra’s picture

Assigned: awolfey » Unassigned
Status: Needs review » Closed (works as designed)

As for the comment in #8, there's no max length for textareas, only number of rows, so what makes more sense is to take care of it in #689212: provide option for limiting number of chars of generated body text