PHPackages                             raftalks/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. [Templating &amp; Views](/categories/templating)
4. /
5. raftalks/form

ActiveLibrary[Templating &amp; Views](/categories/templating)

raftalks/form
=============

Easy way to make Forms with PHP. Specially useful with Laravel 4.

1.3.1(12y ago)311.1k61BSDPHPPHP &gt;=5.3.0

Since Dec 20Pushed 12y ago4 watchersCompare

[ Source](https://github.com/raftalks/Form)[ Packagist](https://packagist.org/packages/raftalks/form)[ RSS](/packages/raftalks-form/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (1)

Form Maker
==========

[](#form-maker)

Form Maker can help buildind forms in PHP. Specially developed package for Laravel 4.

\#Updated to version 1.3.1

- Fixed namespace structure

\##Updated to version 1.2.3 ###Change Log

- Added support to create table, tr, th, td, thead, tbody, etc to generate html Table
- Added additional support for html container type tags
- Added secondary optional parameter to set method for container attributes, example $form-&gt;setNgBind($value, 'ng-bind'); which will force the attribute to be set as given in second parameter.

\##Updated to version 1.2.2 ###Change Log

- Added Support to Share Data across nested Closures
- Added method to share form errors
- Added Support to putText inside a container
- Added support for tag element to fill an array of attributes using method setAttributes()
- Added method include\_all(Closure $callback) to include template in all forms generated
- Fixed bug with Select input type

\##Updated to version 1.2.0 ###Change Log

- Added Support to create Macros
- Added Support to create global Html Tag Decorator
- Added Support to include Template structure for advanced UI interface

\###Upgrade from version 1.0.0

- Download the updates using Composer update command
- In Laravel 4, add the additional class Html class alias

To Use with Laravel 4
---------------------

[](#to-use-with-laravel-4)

Install the package via composer. Now we need to put the class Alias inside L4 app/config/app.php file. Find the aliases key which should be below the providers key and put the following inside its array.

```
	'Form'	 => 'Form\Form',
```

Now you can try using the Form::make(function($form){ ...here you can put the form fields ...});

\#Features Following shows you how this package library is used to make forms.

### New Features added to version 1.2.3

[](#new-features-added-to-version-123)

```
//making table based forms

Form::make('div', function($form))
{
	$form->table(function($table)
	{
		$table->thead(function($table)
		{
			$table->tr(function($tr)
			{
				$tr->th('item');
				$tr->th('category');
			});
		});

		$table->tr(function($tr)
		{
			$tr->td()->ng_bind('item.name','ng-bind');
			$tr->td()->ng_bind('item.category','ng-bind');

			$tr->setNgRepeat('item in list','ng-repeat'); //using second parameter to force the attribute name.
		});

		$table->setClass('table');
	});
});
```

#### New Features added to version 1.2.2

[](#new-features-added-to-version-122)

\####Form elements common to all forms generated When using with a framework like Laravel, you may want to include some element like hidden csrf token in all the forms. We can do this by making a template of csrf and putting it in the Form::include\_all() method.

```
Form::include_all(function()
{
	return Form::template('div',function($form)
	{
		$form->hidden('csrf_token')->value(Session::getToken());
		$form->setClass('token');
	});
});
```

Now we can share variables across nested closure methods. For example we want to pass the POST data or Error messages, which is used to set the value of the field.

```

Form::make(function($form) use($usergroups, $validation_errors)
{

	$form->share('usergroups',$usrgroups);
	$form->share_errors($validation_errors);

	$form->div(function($form)
	{

		$usergroups = $form->get('usergroups');
		$form->select('usergroup_id',trans('user.usergroup'))->options($usergroups);

	});

});
```

#### other new features added includes

[](#other-new-features-added-includes)

```
//sample function to filter errors
function_to_filter_error_by_field($fieldname, $errors)
{
	//filter errors and return matched error
}

//Macro created to show error message for fields
Form::macro('show_error',function($fieldName, $message=null)
{
	return Form::template('span',function($form) use($fieldName, $message)
	{
		$error_messages = $form->get_errors();
		$error_message = function_to_filter_error_by_field($fieldName, $error_messages);

		// the contaner is  and we are
		// adding the error message as text
		$form->putText($error_message);

		// set the container class
		$form->setClass('help-block text-error');

	});
});

// Now we are creating a nother styled input text field which uses
// the above show error macro

Form::macro('input_text', function($name, $label, $value=null, $attr = array())
{
	return Form::template('div',function($form) use ($name, $label, $attr, $value)
	{
			//notice the setAttribute method used here can fill the element with an array
			//of attributes

		$form->text($name)->placeholder($label)->value($value)->setAttributes($attr);

		//we are calling the macro to run the template and show the error message for this input template
		$form->show_error($name);

		$form->setClass('input');
	});
});

// Now we use everything above like this to make a real form.

Form::make(function($form) use($validation_errors)
{
	$form->share_errors($validation_errors);

	//This will run the above macro and will show error messages if any exists
	$form->input_text('username','User Name');

});
```

\####Additional Features added to version 1.2.0

```
//globaly apply attributes to tag elements

	//apply attribute to all text input fields
	Form::decorate('text',function($tag)
	{
		$tag->class('class decorated');
	});

	//Use Form::decorate to apply attribute to all text input fields in templates
	Form::decorate('text',function($tag)
	{
		$tag->class('class decorated');
	});

//Create Form Macros with template

	//bootstrap controlgroup textfield
	Form::macro('group_text',function($name, $label=null)
	{
		return Form::template(function($form) use($name, $label)
		{
			$form->label($label)->class('control-label');

			$form->div(function($form) use($name)
			{
				$form->text($name);
				$form->setClass('controls');
			});

			$form->setClass('group-controls');
		});

	});

	//the above Macro is now available as a Form field type and can be called within a Form

	Form::make(function($form))
	{
		$form->group_text('telephone','Telephone Number');
	}

// will include more use cases later
```

\###version 1.0.0 features

```
echo Form::make(function($form)
{
		$form->div(function($form){ //makes a div container for the enclosed fields

			//creates a text input with label
			$form->text('username','User Name')->class('myname')->value('some name');

			//creates a password input with label
			$form->password('password','Enter Password');

			$form->select('usergroup','User Group')->options(array('admin'=>'admin','manager'=>'manager','user'=>'user'),
									 array('user','admin'))->multiple('multiple');

			$form->setClass('input'); //sets container class
			$form->setId('UserAccount'); //sets container id
		});

		// creates an custom tag element like dome
		$form->group('dome');

		//creates a fieldset container  and enclose the fields in it
		$form->fieldset(function($form)
		{
			$form->legend('HelloWOrld');

			$form->label('Your Address')->for('address'); //create label field separately
			$form->text('address');
		});

		//create Angularjs type input
		$form->text('timer','Time')->ngmodel('time','ng-model');
		$form->select('countries','select country')->ngrepeat('country.name in countries','ng-repeat');

		$form->submit('Save');

		//sets container attributes, therefore, as this is form container, this sets the form attributes
		$form->setId('formIDhere');
		$form->setAction(URL::to('test'));
		$form->setMethod('POST');
		$form->setClass('fill-up');

});
```

Documentation
-------------

[](#documentation)

will be updated soon.

Copyright and License
---------------------

[](#copyright-and-license)

FormMaker was written by Raftalks for the Laravel framework. FormMaker is released under the MIT License. See the LICENSE file for details.

Copyright 2011-2012 Raftalks

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~26 days

Recently: every ~46 days

Total

8

Last Release

4710d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/27342ec143f4eda111c49f7df5eef1cc9f86e9b0ed9c004ac7a51a2a5dc6c91a?d=identicon)[raftalks](/maintainers/raftalks)

---

Top Contributors

[![raftalks](https://avatars.githubusercontent.com/u/788192?v=4)](https://github.com/raftalks "raftalks (29 commits)")

---

Tags

laravelformilluminate

### Embed Badge

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

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

###  Alternatives

[laravie/html

HTML and Form Builders for the Laravel Framework

36184.6k4](/packages/laravie-html)[tomsix/laravel-components-library

A collection of pre-made Blade components for Laravel 7.x and up

613.1k](/packages/tomsix-laravel-components-library)[webup/laravel-form

A Laravel package to help build forms.

147.2k1](/packages/webup-laravel-form)[cornford/bootstrapper

An easy way to intergrate Twitter Bootstrap with Laravel.

232.7k](/packages/cornford-bootstrapper)

PHPackages © 2026

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