PHPackages                             hakimch/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hakimch/form

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

hakimch/form
============

A simple PHP form generator class for PHP 5.6+.

v1.0.1(10y ago)0471MITPHPPHP &gt;=5.4.0

Since Feb 26Pushed 8y ago1 watchersCompare

[ Source](https://github.com/HakimCh/Form)[ Packagist](https://packagist.org/packages/hakimch/form)[ Docs](https://github.com/HakimCh/Utility/blob/master/src/Utility/Component/Form)[ RSS](/packages/hakimch-form/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Form Class
==========

[](#form-class)

A simple html form generator class [![Code Climate](https://camo.githubusercontent.com/aff71ad7a725b9e5d48ced3ae5bd71e09f1814e41e86ed173f45e0589be23358/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f48616b696d43682f466f726d2f6261646765732f6770612e737667)](https://codeclimate.com/github/HakimCh/Form)[![SensioLabsInsight](https://camo.githubusercontent.com/b9f79bff9f20ef7735748a7fce6f25763da1649cb77f39c4e063036d32c81988/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f63393564346263622d396265662d343239322d386433612d6536346261666664383739342f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/c95d4bcb-9bef-4292-8d3a-e64baffd8794)[![Build Status](https://camo.githubusercontent.com/fa39f886a672e7ed66e60ef1e9e25d93aa6ee715622181593223b35febc4e8f8/68747470733a2f2f7472617669732d63692e6f72672f48616b696d43682f466f726d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/HakimCh/Form)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9151d2e3b92bf5fb5c5a324655133e6bdea5d0b35fa8a258e3fe350eaa0ab10b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f48616b696d43682f466f726d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/HakimCh/Form/?branch=master)[![Build Status](https://camo.githubusercontent.com/13020f9fb27d5e959e8d4dc3299f190efadedc37d3c18138cf3120a865c3a1b3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f48616b696d43682f466f726d2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/HakimCh/Form/build-status/master)

Install via composer
====================

[](#install-via-composer)

```
composer require 'hakimch/form'

```

Initialize the form
===================

[](#initialize-the-form)

```
$form = HakimCh\Form\Form::init();
$form->setup(
    $datas, // Submited datas
    $token, // If you want add csrf token (require CSRF class)
    $action // Current url for action attribute
);
echo $form->addAttr([
                'id' => 'Form', // Adding attr Id
                'class' => 'formClass', // adding a class
                'enctype' => 'multipart/form-data' // If you want use it for upload some files
           ])->open();

// you can add fields here

echo $form->close(); // Closing form
```

Add text field
--------------

[](#add-text-field)

You can add many field type as (text,password,date,time,file,hidden,textarea)

```
// Create label(name, for, required)
// Required arg will add *
echo $form->addAttr('for', firstName')->label('firstName', true);
// A normal text field with a name
echo $form->text('firstName');

// Add an Advanced text field with options
echo $form->addAttr([
        'id' => 'secondName',
        'value' => 'Chmimo',
        'class' => 'required greenColor'
      ]) // add attrs by passing an array
      ->text('secondName');
// Add a textarea
echo $form->addAttr('rows',5) // add number of rows
      ->addAttr('class','redBorder') // adding a class name
      ->textarea('about');
```

Add a select
------------

[](#add-a-select)

It accept 2 args (name, options) options as an array with key =&gt; value

```
echo $form->select('record', [1, 2, 3]);
```

Add box field
-------------

[](#add-box-field)

Radio field

```
echo $form->addAttr('value',1)->radio('testRadio', 'Radio 1');
echo $form->addAttr('value',2)->radio('testRadio', 'Radio 2');
```

Checkbox field

```
echo $form->addAttr('value',1)->checkbox('testCheckbox[]', 'Checkbox 1');
echo $form->addAttr('value',2)->checkbox('testCheckbox[]', 'Checkbox 2');
```

Add submit button
-----------------

[](#add-submit-button)

```
// Accept one arg (value)
echo $form->addAttr('class', 'btn btn-success')->submit('Send my Form');
```

\#License (MIT License)

Copyright (c) 2012-2015 Hakim Chmimo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3731d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d91fea4a9e25d7a730a4ae912c55ce77469c25da13c1339c4c405d93b9bd1d9?d=identicon)[HakimCh](/maintainers/HakimCh)

---

Top Contributors

[![HakimCh](https://avatars.githubusercontent.com/u/13296222?v=4)](https://github.com/HakimCh "HakimCh (25 commits)")

---

Tags

formform classphp-form

### Embed Badge

![Health badge](/badges/hakimch-form/health.svg)

```
[![Health](https://phpackages.com/badges/hakimch-form/health.svg)](https://phpackages.com/packages/hakimch-form)
```

###  Alternatives

[kartik-v/yii2-widget-datepicker

Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from yii2-widgets).

1097.0M60](/packages/kartik-v-yii2-widget-datepicker)[kartik-v/yii2-widget-datetimepicker

Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)

1036.5M47](/packages/kartik-v-yii2-widget-datetimepicker)[kartik-v/yii2-widget-depdrop

Widget that enables setting up dependent dropdowns with nested dependencies (sub repo split from yii2-widgets)

814.9M18](/packages/kartik-v-yii2-widget-depdrop)[kartik-v/yii2-widget-typeahead

Enhanced Yii2 wrapper for the Twitter Typeahead plugin (sub repo split from yii2-widgets).

454.8M9](/packages/kartik-v-yii2-widget-typeahead)[kartik-v/yii2-widget-timepicker

Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from yii2-widgets)

404.9M14](/packages/kartik-v-yii2-widget-timepicker)

PHPackages © 2026

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