Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How do i remove default class from textarea using silverstripe forms


Go to End


518 Views

Avatar
thomas.paulson

Community Member, 107 Posts

9 September 2014 at 7:04pm

Edited: 09/09/2014 7:06pm

I have textarea in silverstripe form, i would like to remove the default class ie class="textarea" from the generated html,instead print class="form-control"

$message = new TextareaField('Message', 'Message ' );
$message->addExtraClass('form-control');
$message->setAttribute('placeholder', 'Message (required)');
$message->setAttribute('rows', '5');
$message->setAttribute('cols', '25');

<div id="Message" class="field textarea rounded">
<label class="left" for="Form_Form_Message">
<div class="middleColumn">
<textarea id="Form_Form_Message" class="textarea" cols="20" rows="5" name="Message"></textarea>
</div>
</div>