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.

Form Questions /

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

css + form


Go to End


4 Posts   2284 Views

Avatar
snaip

Community Member, 181 Posts

29 December 2008 at 11:10am

hi

how to add css to input type ?
i have to use addExtraClass() but how to add it to this code ?

      $fields = new FieldSet(
         new TextField('FirstName', 'First name'),
         new EmailField('Email', 'Email addres'),     	      	     	 
      );

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 December 2008 at 12:50pm

You need to store the object in a variable to run a method on it.

$text = new TextField('FirstName', 'First name');
$text->addExtraClass('foo');

$fields = new FieldSet(
$text,
new EmailField('Email', 'Email addres'),
);

Avatar
snaip

Community Member, 181 Posts

31 December 2008 at 7:56am

:) great

i have another problem

how to add title to <input type> ?

      $firstname = new TextField(
      $name = "FirstName", 
      $title = "this field is required", 
      $value = "your name"
      );

doesn't work :/

Avatar
_Vince

Community Member, 165 Posts

9 February 2009 at 1:16pm

Edited: 09/02/2009 1:31pm

$firstname = new TextField(
$name = "FirstName",
$title = "this field is required",
$value = "your name"
);

I'm not exactly an expert, but maybe the extra "$firstname" breaks some sort of behaviour when you are trying to add the title?

If you say...

new TextField(
$name = "FirstName",
$title = "this field is required",
$value = "your name"
);

does that work any better?