Provides a method to capture simple silverstripe forms and a friendly admin interface for users
Provides a method to capture simple silverstripe forms and a friendly admin interface for users.
This version requires silverstripe 4, for 3.1+ compatibility see the 1.* branch.
Either clone/download this repository into a folder named 'silverstripe-form-capture' or run:
composer require andrewhaine/silverstripe-form-capture
After installing you will need to run 'dev/build' and add the module extension to the form class or any subclass of form that you wish to store.
To store submissions from a form simply add a call to the new method in the function you will use to handle the form. See the example below for usage
In the page controller:
public function MyForm() {
$fields = FieldList::create(
TextField('ExampleTextField'),
TextareaField::create('ExampleTextareaField')
);
$actions = FieldList::create(
FormAction::create('doMyForm', 'Submit')
);
$form = Form::create($this, __FUNCTION__, $fields, $actions);
return $form;
}
public function doMyForm($data, $form) {
$form->captureForm();
// Other processing
}
When capturing a form some useful information is returned which can be used in the controller. For example a link is returned to the submission area in the CMS.
$capturedSubmission = $form->captureForm();
echo($capturedSubmission['Link']);
// http://your-site.com/admin/<Link to exact submission>
When calling the captureForm() there are a few optional parameters which will enhance how submission objects are displayed in the CMS.
$form->captureForm('Contact Form Submission', ['IDontWantThisField', 'OrThisOne'], 'Details');
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem