Giter Club home page Giter Club logo

codeigniter4-form's Introduction

CodeIgniter 4 Active Form

Usage

$form = new Form($model, $errors);

echo $form->open();
echo $form->inputGroup($data, 'name', ['id' => 'myinput'], ['label' => 'Custom Label']);
echo $form->renderErrors();
echo $form->beginButtons();
echo $form->submitButton('Submit');
echo $form->endButtons();
echo $form->close();

Generated HTML Code:

<form method="post" accept-charset="utf-8">
    <div class="form-group">
        <label class="form-label">Category</label>
        <input type="text" name="translation_category" value="" class="form-control is-invalid">
    </div>
    <div class="alert alert-danger">The My Field field is required.</div>
    <div>
        <input type="submit" name="submit" value="Create" class="btn btn-primary">
    </div>
</form>

Labels

You can specify the field names in the model.

class MyModel extends \CodeIgniter\Model
{
    
    protected $validationRules = [
        'my_input' => [
            'rules' => 'required',
            'label' => 'My Field'
        ]
    ];

}

You can use all types of input from the form helper of the framework.

Function names and parameters are similar to those used in the framework.

$form->passwordGroup($data, 'name', $attributes, $groupAttributes);
$form->checkboxGroup($data, 'name', $attributes, $groupAttributes);
$form->textareaGroup($data, 'name', $attributes, $groupAttributes);

and all other...

You can also use simple functions to generate a single input.

$form->input($data, 'name', $attributes);
$form->password($data, 'name', $attributes);
$form->checkbox($data, 'name', $attributes);
$form->textarea($data, 'name', $attributes);

and all other...

codeigniter4-form's People

Contributors

denis303 avatar

Stargazers

chirag jagani avatar Efe Tunçer avatar  avatar

Watchers

James Cloos avatar chirag jagani avatar  avatar

Forkers

josephjlee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.