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.
Hi, I'd like to know if it's possible to somehow add maxlength integration for the Privatemsg module's body field.
I tried adding the following code in privatemsg.pages.inc:
$form['body'] = array(
'#type' => 'text_format',
'#title' => t('Message'),
'#rows' => 6,
'#weight' => -3,
'#resizable' => TRUE,
'#format' => isset($format) ? $format : NULL,
'#after_build' => array('privatemsg_check_format_access'),
// Here are my additions
'#maxlength_js' => 'TRUE',
'#maxlength' => '100',
'#attributes' => array(
'maxlength_js_label' => array('Content limited to @limit characters, remaining: <strong>@remaining</strong>')),
);
I arrived at this code by using dpm() on a different textarea for which I had enabled maxlength.
I attached a dpm() of the resulting output. However, this doesn't work.
Is there a way to use maxlength with the Privatemsg body field?
Comment | File | Size | Author |
---|---|---|---|
privatemsg_body.jpg | 72.92 KB | ptmkenny |
Comments
Comment #0.0
ptmkenny CreditAttribution: ptmkenny commentedphp not html comment
Comment #1
mttjn CreditAttribution: mttjn commented@ptmkenny I'm curious, did you get this working?
Comment #2
cedeweyWe are only maintaining the Drupal 7 version of the module for critical security fixes and not providing active support, so I'm marking this Closed (work as designed). Thank you for reporting this issue. If you do want to maintain the Drupal 7 version, do reach out. We'd be happy to bring you on board as a maintainer.
I also encourage you, if you haven't already, to upgrade your site to Drupal 8/9. We are actively maintaining that version and you would enjoy all of the other features of the latest version of Drupal.
Comment #3
cedewey