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

Multiform and conditional/dynamic fields


Go to End


2 Posts   1221 Views

Avatar
rob.s

Community Member, 78 Posts

24 November 2010 at 9:05pm

Edited: 24/11/2010 9:06pm

Hi,

in my MultiForm Step i need fields dependend on the previous step.

Example:
Let's assume we have 2 DataObject classes:
1. Category (has_many Article)
2. Article (has_one Category)

Step1 shows checkboxes of categories.
Step 2 should bring up a checkboxfieldset of all Articles having the CategoryID selected in the first step.

I thought i can access the form data inside the method getFields() in Step2

function getFields() {
		$data = $this->loadData();
		Debug::dump($data);
}

but the debug output is an empty array.

(I also checked the database: all selected CategoryIDs are save correctly. When using the previous button of MultiForm the checkboxes of the first step are also populated correctly)

Any ideas ?

Greetings,

Rob

Avatar
rob.s

Community Member, 78 Posts

24 November 2010 at 9:25pm

Edited: 24/11/2010 9:43pm

I created a workaround:

function getFields() {

		$step = DataObject::get_one(
			'MultiFormStep',
			"SessionID ={$this->Session()->ID} AND ClassName='ProposalTemplateForm_Step1'"
		);
		if($step) {
			$data = $step->loadData();
		}
		....

}