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   2896 Views

Avatar
mage

Community Member, 10 Posts

1 June 2010 at 3:40am

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

Community Member, 5 Posts

16 June 2010 at 3:25am

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

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

Avatar
mitch

Community Member, 3 Posts

6 October 2010 at 10:06am

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

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

Avatar
juneallison

Community Member, 108 Posts

24 September 2013 at 7:47am

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

Thanks!

June