Jump to:

1971 Posts in 1275 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » css + form

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

Page: 1
Go to End
Author Topic: 1448 Views
  • snaip
    Avatar
    Community Member
    180 Posts

    css + form Link to this post

    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'),            
    );

  • UncleCheese
    Avatar
    4085 Posts

    Re: css + form Link to this post

    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'),
    );

  • snaip
    Avatar
    Community Member
    180 Posts

    Re: css + form Link to this post

    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 :/

  • _Vince
    Avatar
    Community Member
    156 Posts

    Re: css + form Link to this post

    $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?

    1448 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.