Giter Site home page Giter Site logo

formmanager's Introduction

FormManager

Manage your forms quickly and safely.

Usage

Include class file started it and create your own form quickly.

<?php

  // include class file
  require 'formmanager.class.php';
  
  $form = new FormManager();
  
  // create your own form quickly
  $form->start();
  $form->input('username', 'Enter username');
  $form->type('password')->input('password', 'Enter Password');
  $form->required(false)->textarea('about', 'Who are you?'); // not required
  $form->submit('Submit');
  $form->end(false); // means don't show
  
  // check before show
  if($data = $form->control()){
    print_r($data);
  } else {
    echo $form->error();
  }
  
  // you can show where you want :)
  $form->show();

Templates

If you want, you can change templates for form elements one by one.

$form->template('input', function(){
  return '<div class="input-example">
    <label for="{name}">
      {form}
      <span class="title">{label}</span>
    </label>
  </div>';
});

$form->template('select', function(){
  return '<div class="select-example">
    <label for="{name}">
      {form}
      <span class="title">{label}</span>
    </label>
  </div>';
});

Radio/Checkbox/Select Examples

$form->start('GET');
$form->label('Who are you?')->textarea('about', 'Write about yourself something');
$form->type('multiple')->value([1,2])->select('hobbies', [
  ''  => '-- select a hobbie',
  '1' => 'Cycling',
  '2' => 'Diving',
  '3' => 'Driving'
]);
 $form->label('Man')->checkbox('gender', 1);
 $form->label('Woman')->checkbox('gender', 2);
 $form->submit('Submit');
 $form->end(false);
 
 echo $form->show();
 
 if ($data = $form->control()){
  print_r($data);
 } else {
  echo $form->error();
 }

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.