I need to set maxlength based on some custom criteria. Is there a way I can set the maxlength of a given field programmatically in the theme or through FAPI? So say, the body field could have a different maxlength for the same field, and the same role, depending on other variables set programmatically. Any help here would be very much appreciated. I've spent a lot of time trying to figure it out. Thanks
Comments
Comment #1
techgirlgeek commentedI'd like this information also, if anyone has any insight. I only want the maxlength set for a specific role.
Comment #2
giorgio79 commented+1
If it would be as easy as for http://drupal.org/project/checkall that would be the best :)
With checkall this is all that is needed:
For maxlength we could have sg like
?>
Comment #3
philpro commentedI needed to add this to just one comment form on one page, here was my solution — it basically mimics the functionality without all the mess. All we really need to populate to make the module take effect is to tell javascript files to load, pass in the js variables 'maxlength' and modify the form element
Comment #4
hefox commentedI plan to make a patch for #984794: Create API for non-node forms that should handle this situation also.
Comment #5
hmdnawaz commentedI used your code but It only displays the Characters remaining: 10 and when I wrote some text it does not decrement the value of Characters remaining.
Comment #6
hefox commented1) Post comment in ticket with patch
2) Set that ticket to needs work
3) mention your browser, steps to reproduce, most importantly, any js errors noticed.
Comment #7
dawehnerYou can use now the api from hefox