2017 © Pedro Peláez
 

library form

A simple form helper

image

swith/form

A simple form helper

  • Sunday, July 31, 2016
  • by SwithFr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Swith Form

Simple helper base on Swith framework., (*1)

How to install ?

composer require swith/form:dev-master, (*2)

How to use ?

require "vendor/autoload.php";

use Swith\Form;

<?=
    Form::start("url_for_action_attribute", "POST", [
        // Here you can configure default options
        "manageErrors" => true, // display error message ?
        "errors" => null, // Array like [ "fieldname" => "error message" ]
        "errorClass" => "hasError", // Default class error
        "showErrorMessage" => true, // show error message in label ?
        "defaultInput" => [
            "class" => '',
            "noError" => false, // manage error for input ?
             "classError" => "hasError", // specific error class
        ],
        "defaultLabel" => [
            "class" => '',
            "noError" => false,
            "classError" => "hasError",
            "errorFormat" => "%MSG%", // Error message format (%MSG% will be replaced by the error message)
        ],
    ])
    ->text("fieldname", "value", $options)
    ->text("name", isset($user->name) ? $user->name : '', [
        "noError" => true // don't manage error for this input
        "label" => "Enter your name"
        "class" => "name_input"
    ])
    ->text("login", isset($user->login) ? $user->login : '', [
        "label" => [
            "title" => "Enter your login"
            "classError" => "your_specific_error_class_for_this_label"
        ]
        "class" => "name_input"
    ])
    ->start_fieldset([
        "class" => "whatever you want"
        "lgend" => "My fieldset" // of course it's optional !
    ])
    ->textarea("fieldname", "content", $options)
    ->password("fieldname", "value", $options)
    // $select_options an array like ["id" => "value"] or an object
    // if it's an object you must provide an option "value" and an optional option "key"
    // ex: $user = {id : 1, name: "Joe"}
    // $options[
    //     "key" => 'id' // default to id
    //     "value" => 'name'
    // ]
    ->select("fieldname", $select_options, $options)
    ->close_fieldset()
    ->end("Send", $senbSubmitOptions)

TODO

add other input type like date, checkbox..., (*3)

The Versions

31/07 2016

dev-master

9999999-dev

A simple form helper

  Sources   Download

by Avatar SwithFr

31/07 2016

dev-develop

dev-develop

A simple form helper

  Sources   Download

by Avatar SwithFr