PHP code example of bigfork / silverstripe-form-capture

1. Go to this page and download the library: Download bigfork/silverstripe-form-capture library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bigfork / silverstripe-form-capture example snippets


public function MyForm()
{
	$fields = FieldList::create(
		TextField::create('Name'),
		EmailField::create('Email'),
		TextareaField::create('Enquiry')
	);

	$actions = FieldList::create(
		FormAction::create('doMyForm', 'Submit')
	);

	$form = Form::create($this, __FUNCTION__, $fields, $actions);

	return $form;
}

public function doMyForm($data, $form)
{
	$form->captureForm(
	    'Enquiry form submission', // Required - type of form submission
	    'Name', // Required (can be null) - form field containing the submitter's name
	    'Email', // Required (can be null) - form field containing the submitter's email address
	    ['Captcha'], // Optional - list of fields that shouldn't be stored
	    ['Enquiry'] // Optional - list of fields to show in "Details" column in CMS
	);

	// Other processing
}

$capturedSubmission = $form->captureForm('Contact form', null, null);

echo($capturedSubmission['Link']);
// http://your-site.com/admin/<Link to exact submission>