2017 © Pedro Peláez
 

silverstripe-module silverstripe-form-extras

Form extras for Silverstripe

image

lekoala/silverstripe-form-extras

Form extras for Silverstripe

  • Friday, June 1, 2018
  • by lekoala
  • Repository
  • 6 Watchers
  • 19 Stars
  • 244 Installations
  • JavaScript
  • 1 Dependents
  • 1 Suggesters
  • 2 Forks
  • 2 Open issues
  • 8 Versions
  • 1 % Grown

The README.md

Silverstripe Form extras module

Utilities to get better forms with Silverstripe, (*1)

Handling jquery, mousewheel and gestures

We try to favor jquery.mousewheel and hammer as librairies to handle mousewheel and gestures. The idea is to try to avoid include other librairies that would do the job twice, leading to duplicated code and extra load time., (*2)

You can use the following helper to load these libraries in your own project:, (*3)

FormExtraJquery::include_jquery();
FormExtraJquery::include_jquery_ui();
FormExtraJquery::include_hammer();
FormExtraJquery::include_mousewheel();

Base form class

New functionnalities

The FormExtra class comes with some simple but nice functionnalities., (*4)

  • It will save and restore the data if the validation fails
  • It provides some response shortcuts (like return $this->err('Failed!') )

There are also two new actions: - FormActionArrow: a form action with an arrow (simple :-) ) - FormActionConfirm: a form action with a confirm text (really, just on onclick="confirm..."), (*5)

Multi steps forms

The FormExtraMulti class implements multi steps functionnality., (*6)

Each step is represented by a single "Form" object. Classes must be named in a sequential manner (Like MyFormStep1, MyFormStep2 ...) because the class name is used to determine which is the current step, the next step etc..., (*7)

Actions are defined by calling, (*8)

$actions = $this->definePrevNextActions()

This will create two actions: doPrev and doNext. doPrev will not be set on the first step while doNext will be translated differently on the last step., (*9)

By default, clicking on these buttons will simply save the data to the session and navigate into the form. It's up to you to override these methods to achieve what you want to do., (*10)

A template is also provided to add steps at the top of your forms. This template consumes the AllSteps method on the form that returns all steps with their properties., (*11)

NOTE: don't forget that validation will happen if you go back (doPrev) in the form. This might not be a desirable behaviour. If used in conjonction with ZenValidator, the FormActionNoValidation will be used to make sure that the validation does not happen when going back (while still saving the current state, allowing the user to freely navigate without losing data)., (*12)

New fields

MiniColorsField

A field that uses the "minicolors" jquery plugin to pick a color. Its best to store the color using the DBColor field instead of a regular Varchar(7). You can set the theme using the MiniColorsField::setTheme method, (*13)

BaseUploadField

An UploadField with a factory method to get an upload field with a folder name already set depending on the context. This context takes into account the current Subsite by default if the module is enabled. Otherwise the tendancy is to put everything in the "Uploads" folder which become quite unmanageable after some time., (*14)

ImageUploadField

An UploadField already set up for image upload, (*15)

Sample usage:, (*16)

$fields->replaceField('Logo', ImageUploadField::createForClass($this, 'Logo'));

FrontendUploadField

An UploadField ready to be used on the frontend. To allow editing on the frontend, make sure that you have a canEditFrontend method that returns true (according to whatever your security settings are)., (*17)

This also adds a "Gallery" functionnality. Supports for "cropbox", "focuspoint" as image resize modules., (*18)

BetterCheckboxField

The default checkbox field in Silverstripe doesn't send any value if not checked. This one does!, (*19)

BirthDateField

If you are like me and that your customers ask you to split the birthdate field in three..., (*20)

ChosenField

A dropdown field integrated with Chosen http://harvesthq.github.io/chosen/, (*21)

CmsInlineFormAction

As you may have noticed, the InlineFormAction class doesn't work quite well. This alternative is bare bones but does the job., (*22)

ComboField

A dropdown where values can be appended by the user., (*23)

MaskedInputField

A field that use Inputmask https://github.com/RobinHerbots/jquery.inputmask, (*24)

PostcodeField

A field that validates postcodes according to a country., (*25)

RegexTextField

A field that validates against a specific regex, (*26)

Select2Field

A field that uses Select2. Version 3 and 4 are supported. https://select2.github.io/, (*27)

SexyPasswordField

A field that validates password according to your Member::password_validator(), (*28)

SliderField

A field that uses jQuery ui slider, (*29)

TableField

A field that supports multiple columns and unlimited rows. Data is stored as json., (*30)

SimpleTinyMceField

A simple TinyMceField plugin for frontend use, (*31)

CropboxField

A field that uses CropboxField, (*32)

GridField

GridFieldConfig_RecordDefault

A default config that uses GridFieldSortableRows, GridFieldOrderableRows and GridFieldBulkManager, (*33)

GridFieldConfig_RelationDefault

A default config that uses GridFieldSortableRows, GridFieldOrderableRows and GridFieldBulkManager, (*34)

GridFieldDownloadButton

WIP, (*35)

GridFieldExportAllButton

The default export to csv button export only the current list, not all items. While this is nice in a way, sometimes your clients want to have a full export. Simple use this button to achieve this., (*36)

NOTE : to make your csv files open nicely on excel, simple use:, (*37)

$btn->setCsvSeparator(';');

HasOne helper

Sometimes, you want to add a button to edit a HasOne relationship or even embed all the fields right inside a tab., (*38)

HasOneButtonField

Simple add the button as any other field:, (*39)

new HasOneButtonField($name,$title,$this);

Embed all fields

Thanks to the HasOneEditDataObjectExtension, all fields named like Relation:Name or Relation/Name will load and save data from and to the Relation., (*40)

new TextField('MyRelation:MyField','My field name')

Recommended modules

Works best with - Zenvalidator : https://github.com/sheadawson/silverstripe-zenvalidator.git - Display Logic : https://github.com/unclecheese/silverstripe-display-logic, (*41)

Compatibility

Tested with 3.1, (*42)

Maintainer

LeKoala - thomas@lekoala.be, (*43)

The Versions

01/06 2018

dev-master

9999999-dev

Form extras for Silverstripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar lekoala

form module cms silverstripe extras

12/06 2017

1.2.4

1.2.4.0

Form extras for Silverstripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar lekoala

form module cms silverstripe extras

07/12 2016

1.2.3

1.2.3.0

Form extras for Silverstripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar lekoala

form module cms silverstripe extras

03/10 2016

1.2.2

1.2.2.0

Form extras for Silverstripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar lekoala

form module cms silverstripe extras

29/01 2016

1.2.1

1.2.1.0

Form extras for Silverstripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar lekoala

form module cms silverstripe extras

12/10 2015

1.2.0

1.2.0.0

Form extras for Silverstripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar lekoala

form module cms silverstripe extras

15/05 2015

1.1.0

1.1.0.0

Form extras for Silverstripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar lekoala

form module cms silverstripe extras

03/04 2015

1.0.0

1.0.0.0

Form extras for Silverstripe

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar lekoala

form module cms silverstripe extras