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.

All other Modules

Discuss all other Modules here.

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

Default Value of Text Field in User Forms


Reply

4 Posts   2875 Views

Avatar
mage

1 June 2010 at 3:40am Community Member, 10 Posts

I'm trying to find out how to give a textfield or textareafield a default value, can anyone help me with this?

I've searched the docs and tried to search the code (as best I can), but can't find it.

Any help appreciated.

Avatar
kidcardboard

16 June 2010 at 3:25am Community Member, 5 Posts

new TextareaField( name, title, rows, cols, value, form)

documentation [url=http://api.silverstripe.org/trunk/forms/fields-basic/TextareaField.html]here[/url]

Avatar
mitch

6 October 2010 at 10:06am Community Member, 3 Posts

To set a default value for a DB field use the $defaults array:

public static $defaults = array(
'Name' => 'John Doe'
);

Avatar
juneallison

24 September 2013 at 7:47am Community Member, 108 Posts

Mitch - Where in the code (which file) would your suggested code go?

Thanks!

June