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

Adding an additional css class to form


Go to End


3 Posts   555 Views

Avatar
Bagzli

Community Member, 71 Posts

20 February 2015 at 3:25pm

Edited: 20/02/2015 3:26pm

Hello,

I'm trying to add custom classes to my form elements, however I keep getting "Sorry, there was a problem with handling your request.". I don't quite understand what I'm doing wrong, according to API's what I have is correct.

$form = new Form($this, 'GameResultForm', $fields, $actions, $requiredFields);
        $form->dataFieldByName('RiotGameID')->addExtraClass('required');
        return $form;

my php error logs are not logging anything

Avatar
Devlin

Community Member, 344 Posts

20 February 2015 at 10:42pm

$form->Fields()->dataFieldByName('RiotGameID')->addExtraClass('required');
// or
$fields->dataFieldByName('RiotGameID')->addExtraClass('required');

http://doc.silverstripe.org/en/developer_guides/forms/introduction/

PS: You need to set the site's environment to 'dev' mode to get proper error notices.

Avatar
Bagzli

Community Member, 71 Posts

21 February 2015 at 1:23am

That worked, thank you!