Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » RequiredFields() on a LiteralField?

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1733 Views
  • Todd
    Avatar
    31 Posts

    RequiredFields() on a LiteralField? Link to this post

    Hi Guys,

    Can you use RequiredFields() on a LiteralField?

    Here is my literalfield:

    new LiteralField("Comments", "<label class='left'>Comments:</label><br //><textarea name='Comments' rows='5' cols='20'></textarea>")

    Thanks,

    Todd

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: RequiredFields() on a LiteralField? Link to this post

    Possibly, but I'm not sure - why not use a TextareaField?

  • Todd
    Avatar
    31 Posts

    Re: RequiredFields() on a LiteralField? Link to this post

    Hi Sam,

    I would. But there would be formatting issues, unless you can tell me how to add a <br /> between "Comments:" and the textarea.

    Todd

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: RequiredFields() on a LiteralField? Link to this post

    Instead of adding a <br /> you can use CSS to make the width of the label long enough that it pushes down the textarea field below the label. I assume that's what you're after.

    Most likely it would be, this, on a TextareaField (assuming you called the field 'Comments'):

    form #Comments label {
    width: 100%;
    display: block;
    }

    Cheers,
    Sean

  • Todd
    Avatar
    31 Posts

    Re: RequiredFields() on a LiteralField? Link to this post

    Hi Sean,

    I'll give this a try.

    Many thanks.

    Todd

    1733 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.