Currently, the module generates long text for text fields like this:
YYvM78jcoXCm4sHuQivbUEuvBqhJzg3bUFwKMNrWEr8p6kgB6KR3u2
which isn't terrible useful, because the long text can break layouts.
Currently, the code can be found in /includes/content.devel.inc
I recommend substituting this line of code within the _text_content_generate() function:
$node_field['value'] = user_password($field['max_length']);
With this:
$node_field['value'] = devel_create_greeking(mt_rand(1, $field['max_length']));
which creates a nice greek title, of some random length between 1 and the maximum length of the field.
Patch is attached.
function _text_content_generate($node, $field) {
$node_field = array();
if ($field['widget']['type'] == 'text_textarea') {
$format = $field['text_processing'] ? rand(0, 3) : 0;
$node_field['value'] = devel_create_content($format);
$node_field['format'] = $format;
}
else {
$allowed_values = content_allowed_values($field);
if (!empty($allowed_values)) {
// Just pick one of the specified allowed values.
$node_field['value'] = array_rand($allowed_values);
}
else {
// Generate a value that respects max_length.
if (empty($field['max_length'])) {
$field['max_length'] = 12;
}
$node_field['value'] = devel_create_greeking(mt_rand(1, $field['max_length']));
}
}
return $node_field;
}
Comments
Comment #1
Mac Clemmens commentedHere's an improved version. I didn't realize the length needed to be specified in number of words, not number of characters.
If it's shorter than or equal to a maxlength of 12 characters, it still uses the user_password function the length of the field. But if it's longer, it makes a nice greek title. If it's really long, it makes a paragraph.
Updated patch attached.
Comment #2
gagarine commentedThis is in text.devel_generate.inc in the devel module now.
+1 for this feature
Comment #3
salvisSimilar issue #1151288: Use lorem ipsum for text field content
Comment #4
rickvug commentedAttached is an initial patch updated to D7. It does not include the additional logic based on the length of the field.
Comment #5
brenes commentedGreat, thank you for your patch. Applied against Devel 7.x-1.0 and it works as described in #4.
Comment #6
salvisSo, should we commit this "initial patch" or do we wait for an improved version?
Comment #7
tauno commentedThe initial patch does what it says and seems to be an improvement over the current behavior. Seems like more customized behavior could ultimately be handled by #1326204: Allow field generate function to be alterable, if it gets committed.
Comment #8
Countzero commentedTried the patch in #4 : content looks really nicer. Thanks a lot.
Comment #9
afmdsouza commentedApplied patch at #4 on the latest dev version, works fine. Thanks for the patch!
Comment #10
salvisSo what do we do with #4
?
Comment #11
dkingofpa commentedThe patch in #4 fixes the issue of the long unbroken password text generated for text fields. It doesn't include the logic for generating different text lengths based on the max-length of the field. I don't think that logic is necessary to get this patch committed. Layouts are being broken with devel generated text right now! :)
Comment #12
moshe weitzman commentedCommitted #4 to 7.x and 8.x. Leaving open for Field issue.
Comment #13
willzyx commentedClosing for lack of activity. Feel free to reopen if the issue still exists