mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 11:05:49 +02:00
ENHANCEMENT Update README and add codesniffer rules
This commit is contained in:
parent
09bcc63874
commit
7532724eb7
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -4,3 +4,4 @@
|
|||||||
/.gitignore export-ignore
|
/.gitignore export-ignore
|
||||||
/.travis.yml export-ignore
|
/.travis.yml export-ignore
|
||||||
/.scrutinizer.yml export-ignore
|
/.scrutinizer.yml export-ignore
|
||||||
|
/.codecov.yml export-ignore
|
||||||
|
@ -14,6 +14,8 @@ matrix:
|
|||||||
env: DB=PGSQL PHPUNIT_TEST=1
|
env: DB=PGSQL PHPUNIT_TEST=1
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
||||||
|
- php: 7.2
|
||||||
|
env: DB=MYSQL PHPUNIT_TEST=1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
# Init PHP
|
# Init PHP
|
||||||
|
35
README.md
35
README.md
@ -1,10 +1,8 @@
|
|||||||
# MultiForm Module
|
# MultiForm Module
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/silverstripe/silverstripe-multiform.svg?branch=master)](https://travis-ci.org/silverstripe/silverstripe-multiform)
|
[![Build Status](https://travis-ci.org/silverstripe/silverstripe-multiform.svg?branch=master)](https://travis-ci.org/silverstripe/silverstripe-multiform)
|
||||||
[![Latest Stable Version](https://poser.pugx.org/silverstripe/multiform/version.svg)](https://github.com/silverstripe/silverstripe-multiform/releases)
|
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/silverstripe/silverstripe-multiform.svg)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-multiform/?branch=master)
|
||||||
[![Latest Unstable Version](https://poser.pugx.org/silverstripe/multiform/v/unstable.svg)](https://packagist.org/packages/silverstripe/multiform)
|
[![Code Coverage](https://img.shields.io/codecov/c/github/silverstripe/silverstripe-multiform.svg)](https://codecov.io/gh/silverstripe/silverstripe-multiform)
|
||||||
[![Total Downloads](https://poser.pugx.org/silverstripe/multiform/downloads.svg)](https://packagist.org/packages/silverstripe/multiform)
|
|
||||||
[![License](https://poser.pugx.org/silverstripe/multiform/license.svg)](https://github.com/silverstripe/silverstripe-multiform/blob/master/license.md)
|
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
@ -22,11 +20,12 @@ individual implementation can be customized to the project requirements.
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
SilverStripe 4.0+. For SilverStripe 3 support please use `1.3` or below.
|
* SilverStripe ^4.0
|
||||||
|
|
||||||
|
**Note:** For a SilverStripe 3.x compatible version, please use [the 1.x release line](https://github.com/silverstripe/silverstripe-multiform/tree/1.3).
|
||||||
|
|
||||||
## What it does do
|
## What it does do
|
||||||
|
|
||||||
|
|
||||||
* Abstracts fields, actions and validation to each individual step.
|
* Abstracts fields, actions and validation to each individual step.
|
||||||
* Maintains flow control automatically, so it knows which steps are ahead and
|
* Maintains flow control automatically, so it knows which steps are ahead and
|
||||||
behind. It also can retrieve an entire step process from start to finish, useful
|
behind. It also can retrieve an entire step process from start to finish, useful
|
||||||
@ -84,7 +83,7 @@ SilverStripe site using this command (while in the directory where your site is
|
|||||||
currently located)
|
currently located)
|
||||||
|
|
||||||
```
|
```
|
||||||
composer require "silverstripe/multiform:*"
|
composer require silverstripe/multiform
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Create subclass of MultiForm
|
### 2. Create subclass of MultiForm
|
||||||
@ -96,7 +95,8 @@ For the above example, our multi-form will be called *SurveyForm*
|
|||||||
```php
|
```php
|
||||||
use SilverStripe\MultiForm\Forms\MultiForm;
|
use SilverStripe\MultiForm\Forms\MultiForm;
|
||||||
|
|
||||||
class SurveyForm extends MultiForm {
|
class SurveyForm extends MultiForm
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -173,8 +173,7 @@ Keep in mind that our multi-form also requires an end point. This step is the
|
|||||||
final one, and needs to have another variable set to let the multi-form system know
|
final one, and needs to have another variable set to let the multi-form system know
|
||||||
this is the final step.
|
this is the final step.
|
||||||
|
|
||||||
So, if we assume that the last step in our process is
|
So, if we assume that the last step in our process is OrganisationDetailsStep, then we can do something like this:
|
||||||
SurveyFormOrganisationDetailsStep, then we can do something like this:
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use SilverStripe\MultiForm\Models\MultiFormStep;
|
use SilverStripe\MultiForm\Models\MultiFormStep;
|
||||||
@ -182,6 +181,8 @@ use SilverStripe\MultiForm\Models\MultiFormStep;
|
|||||||
class OrganisationDetailsStep extends MultiFormStep
|
class OrganisationDetailsStep extends MultiFormStep
|
||||||
{
|
{
|
||||||
private static $is_final_step = true;
|
private static $is_final_step = true;
|
||||||
|
|
||||||
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -328,10 +329,10 @@ template.
|
|||||||
|
|
||||||
### 7. Loading values from other steps
|
### 7. Loading values from other steps
|
||||||
|
|
||||||
There are several use cases were you want to pre-populate a value based
|
There are several use cases where you want to pre-populate a value based on the submission value of another step.
|
||||||
based on the submission value of another step. There are two methods supporting this:
|
There are two methods supporting this:
|
||||||
|
|
||||||
* `getValueFromOtherStep()` load any submitted value from another step from the session
|
* `getValueFromOtherStep()` loads any submitted value from another step from the session
|
||||||
* `copyValueFromOtherStep()` saves you the repeated work of adding the same lines of code again and again.
|
* `copyValueFromOtherStep()` saves you the repeated work of adding the same lines of code again and again.
|
||||||
|
|
||||||
Here is an example of how to populate the email address from step 1 in step2 :
|
Here is an example of how to populate the email address from step 1 in step2 :
|
||||||
@ -460,9 +461,9 @@ use SilverStripe\ORM\DataObject;
|
|||||||
|
|
||||||
class Organisation extends DataObject
|
class Organisation extends DataObject
|
||||||
{
|
{
|
||||||
private static $db = array(
|
private static $db = [
|
||||||
// Add your Organisation fields here
|
// Add your Organisation fields here
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
#### Warning
|
#### Warning
|
||||||
@ -530,7 +531,7 @@ class MyStep extends MultiFormStep
|
|||||||
public function getNextStep()
|
public function getNextStep()
|
||||||
{
|
{
|
||||||
$data = $this->loadData();
|
$data = $this->loadData();
|
||||||
if($data['Gender'] == 'Male') {
|
if(isset($data['Gender']) && $data['Gender'] == 'Male') {
|
||||||
return TestThirdCase1Step::class;
|
return TestThirdCase1Step::class;
|
||||||
} else {
|
} else {
|
||||||
return TestThirdCase2Step::class;
|
return TestThirdCase2Step::class;
|
||||||
@ -632,7 +633,7 @@ after their creation.
|
|||||||
|
|
||||||
You can run the task from the URL, by using http://mysite.com/dev/tasks/MultiFormPurgeTask?flush=1
|
You can run the task from the URL, by using http://mysite.com/dev/tasks/MultiFormPurgeTask?flush=1
|
||||||
|
|
||||||
MultiFormPurgeTask is a subclass of *BuildTask*, so can be , so can be run using the [SilverStripe CLI tools](http://doc.silverstripe.org/framework/en/topics/commandline).
|
MultiFormPurgeTask is a subclass of *BuildTask*, so can be run using the [SilverStripe CLI tools](http://doc.silverstripe.org/framework/en/topics/commandline).
|
||||||
|
|
||||||
One way of automatically running this on a UNIX based machine is by cron.
|
One way of automatically running this on a UNIX based machine is by cron.
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "silverstripe/multiform",
|
"name": "silverstripe/multiform",
|
||||||
"description": "SilverStripe forms with multiple steps, flow control and state persistence",
|
"description": "SilverStripe forms with multiple steps, flow control and state persistence",
|
||||||
"type": "silverstripe-module",
|
"type": "silverstripe-vendormodule",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"silverstripe",
|
"silverstripe",
|
||||||
"forms"
|
"forms"
|
||||||
],
|
],
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Ingo Schommer",
|
"name": "Ingo Schommer",
|
||||||
@ -17,12 +18,12 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "^4@dev"
|
"silverstripe/framework": "^4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^5.7",
|
"phpunit/phpunit": "^5.7",
|
||||||
"squizlabs/php_codesniffer": "^3.0",
|
"squizlabs/php_codesniffer": "^3.0",
|
||||||
"silverstripe/versioned": "^1@dev"
|
"silverstripe/versioned": "^1"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
@ -35,7 +36,6 @@
|
|||||||
"SilverStripe\\MultiForm\\Tests\\": "tests/"
|
"SilverStripe\\MultiForm\\Tests\\": "tests/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"license": "BSD-3-Clause",
|
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
19
lang/en.yml
19
lang/en.yml
@ -1,11 +1,18 @@
|
|||||||
en:
|
en:
|
||||||
SilverStripe\MultiForm\MultiForm:
|
SilverStripe\MultiForm\Models\MultiFormSession:
|
||||||
|
PLURALNAME: 'Multi Form Sessions'
|
||||||
|
PLURALS:
|
||||||
|
one: 'A Multi Form Session'
|
||||||
|
other: '{count} Multi Form Sessions'
|
||||||
|
SINGULARNAME: 'Multi Form Session'
|
||||||
|
SilverStripe\MultiForm\Models\MultiFormStep:
|
||||||
BACK: Back
|
BACK: Back
|
||||||
NEXT: Next
|
NEXT: Next
|
||||||
SUBMIT: Submit
|
|
||||||
SilverStripe\MultiForm\MultiFormSession:
|
|
||||||
PLURALNAME: 'Multi Form Sessions'
|
|
||||||
SINGULARNAME: 'Multi Form Session'
|
|
||||||
SilverStripe\MultiForm\MultiFormStep:
|
|
||||||
PLURALNAME: 'Multi Form Steps'
|
PLURALNAME: 'Multi Form Steps'
|
||||||
|
PLURALS:
|
||||||
|
one: 'A Multi Form Step'
|
||||||
|
other: '{count} Multi Form Steps'
|
||||||
SINGULARNAME: 'Multi Form Step'
|
SINGULARNAME: 'Multi Form Step'
|
||||||
|
SUBMIT: Submit
|
||||||
|
SilverStripe\MultiForm\MultiForm:
|
||||||
|
ProgressPercent: 'You''ve completed {percent}% ({completedSteps}/{totalSteps})'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2017, SilverStripe Limited
|
Copyright (c) 2018, SilverStripe Limited
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
9
phpcs.xml.dist
Normal file
9
phpcs.xml.dist
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ruleset name="SilverStripe">
|
||||||
|
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
|
||||||
|
|
||||||
|
<rule ref="PSR2" >
|
||||||
|
<!-- Current exclusions -->
|
||||||
|
<exclude name="PSR1.Methods.CamelCapsMethodName" />
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
@ -25,7 +25,7 @@ use SilverStripe\ORM\DataObject;
|
|||||||
* you have to allow the following methods:
|
* you have to allow the following methods:
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* private static $allowed_actions = array('next','prev');
|
* private static $allowed_actions = ['next','prev'];
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user