How can I add a class name or assign an ID to a form element that I can use to reference to it on my css files.
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.
Hey Bagzli,
It's a piece of cake to do.
Just have a look at the sample I made below.
Just adapt it to your own code and you're good to go!
function Form(){
$actions = new FormAction('submit', 'Submit Form');
$textfield = new TextField('Text');
$textfield->setAttribute('class', 'your-class-name goes-here you-can-have-as-much-as-you-want');
$emailfield = new EmailField('Email');
$emailfield->setAttribute('id', 'enter-your-id-here');
$fields = new FieldList(
$textfield,
$emailfield
);
$form = new Form($this, 'Form', $actions, $fields);
new $form;
}
Just make sure you have the CSS linked up to the page with the respective form on it and you'll be sussed out in no time! :)
Let me know how you go,
Stephen
Thank you very much!
Thank you very much.
<a href="http://Cookie-Jar.net">Quan ao tre em</a>
<a href="http://Cookie-Jar.net/shop">Quan ao tre em</a>