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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

generic views edit form

Go to End

2 Posts   1565 Views


Community Member, 63 Posts

4 February 2010 at 11:59am

Can I override a particular field in a scaffolded form and if so where?

I have defined the field in the $db array to be of type Text but am using a DropdownField to populate it, so when I use the edit form a text box is being shown without the other options.

I have other fields in my $db array using the Enum type and they are showing in the edit form with a DropdownField type, but using an Enum type for my Text field above would result in cryptic options being displayed (i.e the values of the Dropdownfield).

I'm guessing I need to reuse my initial form on the 'Contoller extends Page_Controller' but in an edit mode with the fields pre-populated instead.

Does anybody have a link or sample code for this?



Community Member, 66 Posts

3 September 2011 at 10:42am

Use scaffoldSearchFields() in your class... eg.

	public function scaffoldSearchFields() 
		$fields = parent::scaffoldSearchFields();

		//override fields
		$updatedField = new Textfield(...)

		$fields->replaceField('FieldName', $updatedField);
		return $fields;