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

How do I add additional text in a contact form


Go to End


3 Posts   1653 Views

Avatar
robskinn

Community Member, 12 Posts

17 June 2015 at 9:05am

I have a contact form that resides on my page.php with the follower fields

    public function ContactForm() {

            $fields = new FieldList(

            new CheckboxField('Teacher'),
            new CheckboxField('Scientist'),
            new CheckboxField('Artist'),
            new CheckboxField('Writer'),
            new TextField('Name'),
            new EmailField('Email'),
            new TextareaField('Message'),
            new CheckboxField('Newsletter')
        ); 

Is there a way that I can add an additional text above the four check boxes saying something 'Like You are a;'
I know it's possible to do this from the html but is it possible to add text in the form function itself?

Avatar
thomas.paulson

Community Member, 107 Posts

17 June 2015 at 7:21pm

Yes you can add LiteralField as below.

        $fields = new FieldList( 
			new LiteralField (
			   $name = "literalfield",
			   $content = '<b>some bold text</b> and <a href="http://silverstripe.com">a link</a>'
			),        
            new CheckboxField('Teacher'),
            new CheckboxField('Scientist'),
            new CheckboxField('Artist'),
            new CheckboxField('Writer'),        
            new TextField('Name'), 
            new EmailField('Email'), 
            new TextareaField('Message')
        ); 

www.kochikl.com

Avatar
robskinn

Community Member, 12 Posts

18 June 2015 at 3:13am

Thanks Thomas, that's exactly what i needed.
Rob