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?

CommentFileSizeAuthor
privatemsg_body.jpg72.92 KBptmkenny
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ptmkenny’s picture

Issue summary: View changes

php not html comment

mttjn’s picture

Issue summary: View changes

@ptmkenny I'm curious, did you get this working?

cedewey’s picture

We 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.

cedewey’s picture

Status: Active » Closed (works as designed)