PHPackages                             stroker/form - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. stroker/form

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

stroker/form
============

ZF2 module for extending forms with live clientside validation

1.0.1(9y ago)4157.1k23[8 issues](https://github.com/bramstroker/zf2-form/issues)[1 PRs](https://github.com/bramstroker/zf2-form/pulls)MITPHPPHP &gt;=5.6 || &gt;= 7.0

Since Feb 14Pushed 5y ago5 watchersCompare

[ Source](https://github.com/bramstroker/zf2-form)[ Packagist](https://packagist.org/packages/stroker/form)[ RSS](/packages/stroker-form/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (17)Versions (13)Used By (0)

StrokerForm
===========

[](#strokerform)

[![Build Status](https://camo.githubusercontent.com/f57ff087171bae5a78a498c789f044563646af46099e4120a3dfbd8fe1ff4cee/68747470733a2f2f7472617669732d63692e6f72672f6272616d7374726f6b65722f7a66322d666f726d2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/bramstroker/zf2-form)[![Coverage Status](https://camo.githubusercontent.com/663fcfebfdb8df07d96f3f77a0ec70a2507dab6c0148e2740a763deef2360a3b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6272616d7374726f6b65722f7a66322d666f726d2f62616467652e706e67)](https://coveralls.io/r/bramstroker/zf2-form)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0a6c416b0aa2c06c5cf05324b560d2774da66077bdf12dd5c7b057cfc0303def/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6272616d7374726f6b65722f7a66322d666f726d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bramstroker/zf2-form/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/55a105f4f96515c7912178a796c306f0f441d91df34304467dc72e243672574f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65653333323136312d626233622d343031622d626263652d6638353732353538653939382f6d696e692e706e67)](https://insight.sensiolabs.com/projects/ee332161-bb3b-401b-bbce-f8572558e998)[![Total Downloads](https://camo.githubusercontent.com/f14d378aa1e1c1941d4f9adf5873ecf347706af2b42444e785426d9ab81bcf1c/68747470733a2f2f706f7365722e707567782e6f72672f7374726f6b65722f666f726d2f646f776e6c6f6164732e737667)](https://packagist.org/packages/stroker/form)[![HHVM Status](https://camo.githubusercontent.com/f51c16e2545c25a6a6e493e4b8ef3ca6bfa59a13d668781c1095c7f39b802cd1/687474703a2f2f6868766d2e683463632e64652f62616467652f7374726f6b65722f666f726d2e706e67)](http://hhvm.h4cc.de/package/stroker/form)

ZF2 module for extending forms with live clientside validation without need to write js validation code. You only need to define your validation rules server side with ZF2 and this module automaticaly adds the same rules with [jQueryValidate](http://docs.jquery.com/Plugins/Validation). In case a client side version of the validation rule doesn't exist a fallback is done using ajax. For basic usage examples see the sandbox project [StrokerFormSandbox](https://github.com/bramstroker/zf2-form-sandbox).

BC Breaks since 1.0.0
---------------------

[](#bc-breaks-since-100)

- Support for PHP versions lower than 5.6 is dropped.
- `StrokerForm\Renderer\JqueryValidate\Rule\RuleInterface` has been extended with a new method `canHandle`. This method is called on a rule to check if it can process a certain validator. When you have some custom rules you'll need to update them to implement this new method.

BC Breaks since 0.1.0
---------------------

[](#bc-breaks-since-010)

For the new version you need to copy `config/strokerform.global.php.dist` to your projects `config/autoload` dir.

Installation
------------

[](#installation)

Installation of StrokerForm uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/).

1. `cd my/project/directory`
2. create or modify the `composer.json` file within your ZF2 application file with following contents:

    ```
    {
        "require": {
            "stroker/form": "*"
        }
    }
    ```
3. install composer via `curl -s https://getcomposer.org/installer | php` (on windows, download  and execute it with PHP). Then run `php composer.phar install`
4. open `my/project/directory/configs/application.config.php` and add the following key to your `modules`:

    ```
    'StrokerForm',
    ```
5. copy the file `config/strokerform.global.php.dist` from `vendor\stroker\zf2-form` to your projects `config/autoload` directory and rename it to `strokerform.global.php`.
6. copy the assets to your public folder (my/project/directory/public).

Usage
-----

[](#usage)

First we need to make sure jquery is loaded by our application and the headScript() and inlineScript() view helpers are called. If you already have this in place you can skip this step.

```

  headLink() ?>
	headScript()->prependFile('//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js') ?>

	content; ?>

inlineScript() ?>

```

For the ajax validation to work inputfilters needs to be hooked to the form. We need to create a serviceFactory and register it with a unique alias to the formManager (this is an pluginManager). If the inputFilters are already set to the form (i.e. in your form constructor) it's enough to register the form as an invokable

```
