17488 Posts in 4473 Topics by 1978 members
|Go to End|
26 July 2008 at 3:14am
Is there a way to specify a maximum number of characters in a text field in the CMS? I can't imagine that no one has thought of this! I am looking for the equivalent to the "maxlength" HTML input attribute.
30 July 2008 at 3:59am
The $maxLength variable can be passed when you set up the TextField:
$name = 'Word',
$title = 'Short Word',
$value = $myPage->Word,
$maxLength = 4;
You can also check out the docs for more info:
Hope that helps!
1 August 2008 at 5:40am
Thanks so much for your reply, but it's not working for me. I am still able to type in as many characters as I want, and it publishes successfully. Here's my code:
$fields->addFieldToTab("Root.Content.Main", new TextAreaField('ProjectChallenge', 'The Challenge', '' , 25), 'Content');
What's wrong with this picture??
1 August 2008 at 6:57am
The code you're showing is asking for a TextAreaField. Try again with a TextField...
Let me know how that works out for you!
1 August 2008 at 7:16am
That works, yeah, thanks! Sure wish you could use that for a TextAreaField, though....
|Go to Top|