Download the PHP package antonythorpe/silverstripe-knockout-forms without Composer
On this page you can find all versions of the php package antonythorpe/silverstripe-knockout-forms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download antonythorpe/silverstripe-knockout-forms
More information about antonythorpe/silverstripe-knockout-forms
Files in antonythorpe/silverstripe-knockout-forms
Package silverstripe-knockout-forms
Short Description Provides an enhanced UX using the Knockout MVVM JavaScript library, plus an associated validation plugin, with Silverstripe forms. Silverstripe generates a form, specifying the Knockout styled form fields, and validation needs are added to observables via a Knockout js extension. Default messages are available or can be customised. The submit button will only be enabled upon satisfaction of all the validation rules.
License MIT
Informations about the package silverstripe-knockout-forms
silverstripe-knockout-forms
Provides an enhanced UX for Silverstripe forms using the Knockout MVVM JavaScript library plus an associated validation plugin
Why use this Silverstripe module?
- Prevent incorrect form submission
- Live validation responses
- Present messages via span element or tooltip
- Browser support back to ie6
How it works
Add validation needs to the observables in a Knockoutjs viewModel. Next, utilising the Knockout Form Fields, use Silverstripe to create the form. Upon bind, the field values are passed into the observables via a custom binding handler. The rules placed upon the observable will control the field validation.
The Approach of this Module
- Extend Silverstripe form fields to place a Knockout observable and the value on the element
- Use Knockout-Validation to validate the fields
- Option to disable the submit button until all rules are satisfied
Requirements
Documentation
Index
Future Development Ideas
- Add additional fields
- Explore the use of knockout-pre-render for the display of data in a grid (would replace the setKnockout binding handler and restructure the templates/tests). This library is currently only one dimensional.
Pull Requests are Welcome
The recommended approach is to extend an existing Silverstripe field. Ensure that the appropriate Binding Type is specified and cast getters from trait class Common.php
and add any needed methods.
If needed add the __construct
function to overriding the field's class.
Adapt the Frameworks form templates to incorporate Knockout's binding handlers and save into templates/AntonyThorpe/Knockout
.
Tests
- Create a model test for the new form field
- Update
KnockoutFormTest.php
andKnockoutFormTestController.php
to test the creation of the binding handler in HTML.- Add the new Knockout field to the form function within the KnockoutFormTestController class
- Add a new assertion to the testKnockoutForm function within the KnockoutFormTest class
- Add to
docs/en/documentation.md
Support
None sorry.
Change Log
Link
Contributions
Link
License
MIT