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.

All other Modules /

Discuss all other Modules here.

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

Model admin values for fields not appearing


Go to End


1543 Views

Avatar
Matthew

Community Member, 5 Posts

8 June 2009 at 6:19am

I am trying to set the default values for a new record managed by model admin. I've overridden the getCMSAddFormFields in the class Podcast extends DataObject. it works fine for generating the field, but in the ReadonlyField has a value of (none) when the add button is pressed in the model admin.

I'm still new to this, and don't fully understand the distinction between the model code, and the controller code, but I have a feeling that this is solved by a controller... but can extensions of dataobject even have controllers?

Please Help!!

public function getCMSAddFormFields() {
	{
		return new FieldSet(
		
			new ReadonlyField(
			   $name = "Date",
			   $title = "Select a date",
			   $value = date("d/m/Y")
			),

			new TextField('Name'),
			new TextareaField('Description')

		);
	}


}