Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm trying to add some additional validation to limit the amount of characters but I'm obviously not getting something right.
I started by copying the minimum validation example from the webform documentation page (http://drupal.org/node/237281) thinking it would be a simple switch since I'm doing the exact opposite. Here is the changed code below:
<?php
// The field with the key "plans_after_high_school" must have a maximum of 300 characters.
$max_length = 300;
if (strlen($form_values['plans_after_high_school']) > $max_length) {
form_set_error('plans_after_high_school', 'Too many characters.');
}
?>
The field is in a group, and I tried prefixing the field with the group field key in square brackets.
Any help would be appreciated.
Sincerely,
Rene
Comments
Comment #1
quicksketchThe variable
$form_values['plans_after_high_school']
will not exist, it should be$form_values['submitted_tree']['plans_after_high_school']
Comment #2
quicksketch