PHPackages                             majorman/formbuilder - 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. majorman/formbuilder

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

majorman/formbuilder
====================

Create form elements easily

1.0.0(7y ago)04PHPPHP &gt;=7.1

Since Jan 9Pushed 7y ago1 watchersCompare

[ Source](https://github.com/emexxRepo/formbuilder)[ Packagist](https://packagist.org/packages/majorman/formbuilder)[ RSS](/packages/majorman-formbuilder/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (2)Used By (0)

formbuilder
===========

[](#formbuilder)

Create Form Elements Quickly

INSTALL
=======

[](#install)

```
composer require majorman/formbuilder

```

USAGE
=====

[](#usage)

Create Form
-----------

[](#create-form)

```
echo $form = new Form(
    'foo.php',
    'post',
    ['id' => 'fooID', 'class' => 'fooClass'],
    'multipart/form-data'
    );

/* Result :  */

```

END FORM
--------

[](#end-form)

```

echo $form->endForm();

```

Add Element -&gt; Input
-----------------------

[](#add-element---input)

```
// EXAMPLE :  INPUT TEXT
echo $form->addElement(new Input)
    ->setType('text')
    ->addProperty([
        'onclick' => 'alert(\'Im a alert\')',
        'placeholder' => 'Im placeholder',
        'disabled' => 'disabled',
        'readonly' => 'readonly',
        'class' => 'testClass',
        'id' => 'testId',
    ])->addRule(
        ['min' => 1, 'maxlength' => 25, 'required' => 'required']
    );

/* Result :
*/

```

Add Element -&gt; TextArea
--------------------------

[](#add-element---textarea)

```
//EXAMPLE TEXTAREA
echo $form->addElement(new TextArea)
          ->setValue('Lorem Ipsum dollar')
            ->addRule(['maxlength' => 25])
            ->setName('fooTextArea')
            ->addProperty(['style' => 'background:yellow']);

/* Result : Lorem Ipsum dollar */

```

Add Element SelectBox
---------------------

[](#add-element-selectbox)

```
    echo $form->addElement(new SelectBox)
    ->setName('fooSelectBox')
    ->addProperty(['class' => 'fooCls', 'id' => 'fooId'])
    ->setOptions([
        [
            'name' => 'Audi',
            'value' => 'audi',
            'properties' => [
                'style' => 'color:red'
            ]
        ],

        [
            'name' => 'BMW',
            'properties' => [
                'class' => 'fooClass', 'id' => 'fooId', 'disabled' => 'disabled'
            ],
            'value' => 'bmw'
        ],

        [
            'name' => 'Fiat',
            'value' => 'fiat',
            'selected' => 'selected',
            'properties' => [
                'style' => 'background:pink'
            ]
        ]
    ]);

    /* Result : AudiBMWFiat */

```

### ALL EXAMPLES

[](#all-examples)

```
