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.

Form Questions /

css + form


Reply


4 Posts   1524 Views

Avatar
snaip

Community Member, 180 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

4085 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, 180 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, 161 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?