2017 © Pedro Peláez
 

silverstripe-vendormodule silverstripe-customformpage

Define custom form fields via text input in your CMS

image

pstaender/silverstripe-customformpage

Define custom form fields via text input in your CMS

  • Sunday, April 22, 2018
  • by pstaender
  • Repository
  • 1 Watchers
  • 0 Stars
  • 81 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 6 Versions
  • 7 % Grown

The README.md

Custom Forms with SilverStripe

Define you custom form fields in your created CustomFormPage with this straight forward syntax:, (*1)

    {{ FieldName | My Field: | Dropdown | { "Option1": "Foo", "Option2": "Bar" } }}
    {{ FieldName * | My Required Field: | Textarea }}
    {{ Captcha |  | Recaptcha }}

You can use as many form fields as you like., (*2)

Requirements

  • SilverStripe 4+

Arguments

The following arguments are listed separated by | in each {{ }} form field block (sequence of arguments is not arbitrary):, (*3)

  1. Name: String as CamelCase describing the name of your field; e.g.: Email, FirstName
    • the field is required, if ends with *; e.g.: Email *
  2. Title: String as title, can contain every character except the | seperator; e.g. Your eMail:
  3. Class of Field: Can be every existing field class, without the Field appendix; e.g.: Text, Textarea, Email, Dropdown
  4. (assoc.) Array as option for the field
    • optional
    • must be JSON
    • required for DropDownField for instance

Usage in Templates

You can access the form via $CustomForm:, (*4)

  <% with $MyCustomFormPage %>
    <h1>$Title</h1>
    $CustomForm
  <% end_with %>

Comments and HTML tags

You can use comments # and using html tags. HTML tags will be converted to SilverStripe LiteralFields:, (*5)

    # My advanced Poll Form Desctiption
    {{ Email * | Your eMail (required): | Email }}
    <hr />
    <h2>Additional Information</h2>
    # Description of something
    {{ Age | Your age: | Dropdown | { "Under20": "younger or just 20", "Over20": "older than 20" } }}

Exclude Fields in form submission

You can explicitly prevent fields to be written in the submission. Just define them in your config:, (*6)

CustomFormPageSubmission:
  excludeParameters:
    - Foo
    - Bar

Template variables

You can check $FormWasSuccessfullySended and $FormWasSubmitted in your template., (*7)

License

(C) 2017 by Philipp Staender, MIT Licence, (*8)

The Versions

22/04 2018

dev-master

9999999-dev https://github.com/pstaender/silverstripe-customformpage

Define custom form fields via text input in your CMS

  Sources   Download

MIT

The Requires

 

by Philipp Staender

form silverstripe customize

22/04 2018

v0.3.0

0.3.0.0 https://github.com/pstaender/silverstripe-customformpage

Define custom form fields via text input in your CMS

  Sources   Download

MIT

The Requires

 

by Philipp Staender

form silverstripe customize

22/04 2018

dev-ss4

dev-ss4 https://github.com/pstaender/silverstripe-customformpage

Define custom form fields via text input in your CMS

  Sources   Download

MIT

The Requires

 

by Philipp Staender

form silverstripe customize

22/04 2018

v0.2.1

0.2.1.0 https://github.com/pstaender/silverstripe-customformpage

Define custom form fields via text input in your CMS

  Sources   Download

MIT

The Requires

 

by Philipp Staender

form silverstripe customize

19/02 2017

v0.2

0.2.0.0 https://github.com/pstaender/silverstripe-customformpage

Define custom form fields via text input in your CMS

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

by Philipp Staender

form silverstripe customize

07/02 2017

v0.1

0.1.0.0 https://github.com/pstaender/silverstripe-customformpage

Define custom form fields via text input in your CMS

  Sources   Download

MIT

The Requires

  • php >=5.2.0

 

by Philipp Staender

form silverstripe customize