diff --git a/README.md b/README.md index 38bb59f..416f42b 100644 --- a/README.md +++ b/README.md @@ -83,24 +83,14 @@ currently located) ### 2. Create subclass of MultiForm -First of all, we need to create a new subclass of *MultiForm*, which can be -called anything. +First of all, we need to create a new subclass of *MultiForm*. -A suggestion for a good name, is an abbreviation of the project this multi-form -is for, with "MultiForm" appended to the end. For example, if I was doing a -site called "Bob's Chicken Shack" then a good name would be *BCSMultiForm*. -This makes sense, as it is specific to the project that you're developing a -multi-form for. - -Keep in mind the PHP file you create must be in the `mysite/code` directory, and -the filename must be the same as the class name, with the `.php` extension. - -For the above example, our multi-form will be called *BCSMultiForm.php* +For the above example, our multi-form will be called *SurveyForm* :::php - <% if Content %> + <% if $Content %> $Content <% end_if %> - <% if BCSMultiForm %> - $BCSMultiForm + <% if $SurveyForm %> + $SurveyForm <% end_if %> - <% if Form %> + <% if $Form %> $Form <% end_if %> @@ -288,31 +278,31 @@ To include these with our instance of multiform, we just need to add an For example: :::html - <% with BCSMultiForm %> + <% with $SurveyForm %> <% include MultiFormProgressList %> <% end_with %> This means the included template is rendered within the scope of the -BCSMultiForm instance returned, instead of the top level controller context. +SurveyForm instance returned, instead of the top level controller context. This gives us the data to show the progression of the steps. Putting it together, we might have something looking like this: :::html
- <% if Content %> + <% if $Content %> $Content <% end_if %> - <% if BCSMultiForm %> - <% with BCSMultiForm %> + <% if $SurveyForm %> + <% with $SurveyForm %> <% include MultiFormProgressList %> <% end_with %> - $BCSMultiForm + $SurveyForm <% end_if %> - <% if Form %> + <% if $Form %> $Form <% end_if %>
@@ -334,7 +324,7 @@ The default progress indicators make use of the above functions in the templates. To use a custom method of your own, simply create a new method on your subclass -of MultiForm. In this example, *BCSMultiForm* would be the one to customise. +of MultiForm. In this example, *SurveyForm* would be the one to customise. This new method you create would then become available in the progress indicator template. @@ -356,9 +346,9 @@ Here is an example of what we could do here: :::php class == 'BCSPersonalDetailsFormStep') { + if($step->class == 'SurveyFormPersonalDetailsStep') { $member = new Member(); $data = $step->loadData(); @@ -380,7 +370,7 @@ Here is an example of what we could do here: } } - if($step->class == 'BCSOrganisationDetailsFormStep') { + if($step->class == 'SurveyOrganisationDetailsStep') { $organisation = new Organisation(); $data = $step->loadData(); @@ -399,20 +389,19 @@ Here is an example of what we could do here: } } - $controller = $this->getController(); - $controller->redirect($controller->Link() . 'finished'); + $this->controller->redirect($controller->Link() . 'finished'); } } -#### Organization +#### 8. Organisation data model The class Organisation is mentioned in the above example but doesn't exist at the moment (unlike the existing Member() class which looks after the member groups in SilverStripe) so we need to create it: -(I have chosen in this example to create Organisation as a separate DataObject -but you may wish to change the code and add the data to the Member class). +This example has been chosen as a separate DataObject but you may wish to change +the code and add the data to the Member class instead. :::php