PHPackages                             raffaelj/cockpit-formvalidation - 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. raffaelj/cockpit-formvalidation

ActiveCockpit-module[Validation &amp; Sanitization](/categories/validation)

raffaelj/cockpit-formvalidation
===============================

A form validator and form builder for Cockpit CMS v1

0.4.1(3y ago)1111014MITPHP

Since Aug 9Pushed 3y ago4 watchersCompare

[ Source](https://github.com/raffaelj/cockpit_FormValidation)[ Packagist](https://packagist.org/packages/raffaelj/cockpit-formvalidation)[ Docs](https://github.com/raffaelj/cockpit_FormValidation)[ RSS](/packages/raffaelj-cockpit-formvalidation/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (7)Used By (4)

Form Validation Addon for Cockpit
=================================

[](#form-validation-addon-for-cockpit)

**This addon is not compatible with Cockpit CMS v2.**

See also [Cockpit CMS v1 docs](https://v1.getcockpit.com/documentation), [Cockpit CMS v1 repo](https://github.com/agentejo/cockpit) and [Cockpit CMS v2 docs](https://getcockpit.com/documentation/), [Cockpit CMS v2 repo](https://github.com/Cockpit-HQ/Cockpit).

---

Form validator and form builder for [Cockpit CMS v1](https://github.com/agentejo/cockpit). I mainly use it in combination with [CpMultiplane](https://github.com/raffaelj/CpMultiplane), but it should be compatible with plain rest api usage.

Work in progress! Feel free to contribute with code, bug reports or feature requests.

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

[](#installation)

Copy this repository into `/addons` and name it `FormValidation` or use the cli.

### via git

[](#via-git)

```
cd path/to/cockpit
git clone https://github.com/raffaelj/cockpit_FormValidation.git addons/FormValidation
```

### via cp cli

[](#via-cp-cli)

```
cd path/to/cockpit
./cp install/addon --name FormValidation --url https://github.com/raffaelj/cockpit_FormValidation/archive/master.zip
```

### via composer

[](#via-composer)

Make sure, that the path to cockpit addons is defined in your projects' `composer.json` file.

```
{
    "name": "my/cockpit-project",
    "extra": {
        "installer-paths": {
            "addons/{$name}": ["type:cockpit-module"]
        }
    }
}
```

```
cd path/to/cockpit-root
composer create-project --ignore-platform-reqs aheinze/cockpit .
composer config extra.installer-paths.addons/{\$name} "type:cockpit-module"

composer require --ignore-platform-reqs raffaelj/cockpit-formvalidation
```

Requirements:
-------------

[](#requirements)

- Cockpit version &gt;= 0.12.2
- PECL intl extension is suggested for punycode conversion of urls and mail adresses

Features
--------

[](#features)

### Form builder

[](#form-builder)

**Field types:**

- boolean (check box)
- text
- textarea
- date
- select
- multipleselect
- content block (rich text stored as `field.content`)
- honeypot (with default attributes for a hidden input field)
- file (doesn't work out of the box - there is an [example for advanced usage](https://github.com/raffaelj/CpMultiplane/blob/master/modules/Multiplane/module/forms.php#L14) in the CpMultiplane source until I'll update the docs for it here)

It's meant for strings and I don't know (yet), what happens if it should validate arrays.

In the frontend it's possible to reuse some form options like "info", "label", "group", "lst", "width".

...

### Form Validator

[](#form-validator)

- checks for required fields
- checks for content types
- sends response if validation fails

The idea is to add multiple checks on each field to trick spambots without using a captcha.

some templating
---------------

[](#some-templating)

- custom mail subject
- field for reply to

see screenshots below

How to use
----------

[](#how-to-use)

Create a field and click on "Validate" tab. Click on "Validate form data" to activate the validator.

When the validator is active, it checks, if required fields are present. If you want to allow sending fields, that aren't present in the form builder, you have to click "Allow extra fields".

To activate more validations, click on "Validate" for each field and add some json.

### mail field

[](#mail-field)

Create a text field.

```
{
  "type": {
    "mail": true,
    "url": false
  }
}
```

### Honeypot

[](#honeypot)

Create a boolean field and name it "confirm". Spambots will love it :-D

```
{
  "honeypot": {
    "fieldname": "confirm",
    "expected_value": "0",
    "response": "Hello spambot. A human wouldn't fill this field."
  }
}
```

If `"response": "404"`, sender gets a `404 Path not found` instead of a json response.

...

defaults:
---------

[](#defaults)

- if form validation is active
    - key names must be alphanumeric (a-zA-Z0-9) or '-' or '\_'
    - check, if required fields are present
    - sending data with unknown field names is not allowed
- if field validation is active
    - no defaults, only specified validations

Notes
-----

[](#notes)

- Validating to `type:{"phone":false}` could lead to false positives. The regex is meant to allow inputs like "0123 45678" or "+49 123-456-78", but "123" returns true, too.

i18n
----

[](#i18n)

Use the [Babel addon](https://github.com/raffaelj/cockpit_Babel)

To do
-----

[](#to-do)

- allow mail addresses with special chars (punycode) - they are valid, but `filter_var($to, FILTER_VALIDATE_EMAIL)` returns false
    - --&gt; overwrite original submit function again or
    - --&gt; change the mail validation in cockpit core --&gt; [now in core](https://github.com/agentejo/cockpit/commit/745df212d02be2609b5d13ff81aaa4226f68fb32)
- i18n of error responses
- friendly error responses --&gt; use i18n
- add a view to include via PHP frontend

matches:

- required (!empty)
- honeypot (humans wouldn't fill this field)
- type (mail, phone, url)
- !type (inverse type)
- equals (= string) (for simple captchas or something like "Are you really sure? Type 'Yes'")
- contains
    - code
    - url(s)
    - string

types:

- mail
- phone
- url
- number
- bool
- ascii
- date --&gt; must be i18n specific
- ...

Form Mail Template Example
--------------------------

[](#form-mail-template-example)

Create a custom mail template in `config/forms/emails/formname.php` to use the settings `email_text_before` and `email_text_after`.

[Example](/templates/emails/contactform.php)

Screenshots
-----------

[](#screenshots)

[![formbuilder](https://user-images.githubusercontent.com/13042193/45387246-cb872400-b615-11e8-975a-5964e4b8a08b.png)](https://user-images.githubusercontent.com/13042193/45387246-cb872400-b615-11e8-975a-5964e4b8a08b.png)

[![validation_01](https://user-images.githubusercontent.com/13042193/45387250-cc1fba80-b615-11e8-9b7c-e8e04308a0f9.png)](https://user-images.githubusercontent.com/13042193/45387250-cc1fba80-b615-11e8-9b7c-e8e04308a0f9.png)

[![honeypot](https://user-images.githubusercontent.com/13042193/45387248-cc1fba80-b615-11e8-9ce6-81fc2993078a.png)](https://user-images.githubusercontent.com/13042193/45387248-cc1fba80-b615-11e8-9ce6-81fc2993078a.png)

[![responses](https://user-images.githubusercontent.com/13042193/45387249-cc1fba80-b615-11e8-95ea-f1bd4d9f8b35.png)](https://user-images.githubusercontent.com/13042193/45387249-cc1fba80-b615-11e8-95ea-f1bd4d9f8b35.png)

Credits and third party libraries
---------------------------------

[](#credits-and-third-party-libraries)

Icons are from Cockpit CMS v2, (c) Artur Heinze, , MIT License

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~171 days

Recently: every ~198 days

Total

6

Last Release

1239d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef4edcadbb34e2b59a6e5320ea13b3e53b8c9d3ba08f4387f479f11cfa7d950b?d=identicon)[raffaelj](/maintainers/raffaelj)

---

Top Contributors

[![raffaelj](https://avatars.githubusercontent.com/u/13042193?v=4)](https://github.com/raffaelj "raffaelj (124 commits)")

---

Tags

validationcockpitForms

### Embed Badge

![Health badge](/badges/raffaelj-cockpit-formvalidation/health.svg)

```
[![Health](https://phpackages.com/badges/raffaelj-cockpit-formvalidation/health.svg)](https://phpackages.com/packages/raffaelj-cockpit-formvalidation)
```

###  Alternatives

[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M446](/packages/nette-forms)[karser/karser-recaptcha3-bundle

Google ReCAPTCHA v3 for Symfony

1862.4M7](/packages/karser-karser-recaptcha3-bundle)[pear/html_quickform2

Provides methods to create, validate and render HTML forms in PHP.

24498.9k2](/packages/pear-html-quickform2)[sheadawson/silverstripe-zenvalidator

Faster, easier client and server-side form validation for SilverStripe

5778.4k2](/packages/sheadawson-silverstripe-zenvalidator)[hybridlogic/validation

A simple, extensible validation library for PHP with support for filtering and validating any input array along with generating client side validation code.

641.1k](/packages/hybridlogic-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
