Skip to content

stockenberg/FormGenerator

Repository files navigation

FormGenerator by Marten Stockenberg
GNU General Public License v3.0

Styles, JS and Form Components Copyright 2014-2016 Materialize http://materializecss.com/

Composer Autoload

"autoload": { "psr-4": { "FormGenerator\\": "FormGenerator/" } }

Documentation

Questions? -> MStockenberg [AT] gmail [DOT] com
Demo: http://formgen.mstockenberg.de

Min Setup

Get Right Library
$form = new \FormGenerator\Views\FormMaterialize();
Start Form
$form->addElement("Form"); $form->form = "start"; $form->action = "#"; $form->method = "post"; $form->id = "Register";
Add Element
$form->addElement("Input"); $form->headline = "<h5>Input</h5>"; $form->type = "text"; $form->label = "Normal Textbox"; $form->classes = "validate"; $form->id = "normal";
Close Formtag
$form->addElement("Form"); $form->form = "end";
Rendering
$form->Output();

Lazy Features

$form = new \FormGenerator\Views\FormMaterialize();
$form->addElement("Form"); $form->form = "start"; $form->method = "post"; $form->action = "#"; $form->id = "myForm";
$form->addElement("Input", "firstname"); $form->addElement("Input", "lastname"); $form->addElement("Input", "phone"); $form->addElement("Input", "street"); $form->addElement("Input", "postcode"); $form->addElement("Input", "city"); $form->addElement("Input", "email"); $form->addElement("Textarea", "message"); $form->addElement("Input", "paypal"); $form->addElement("Input", "sofort"); $form->addElement("Input", "prepaid"); $form->addElement("Input", "agb"); $form->addElement("Input", "submit");
$form->addElement("Form"); $form->form = "end";

Parameter

    Global
  • name
  • ID
  • classes "first scnd third ..."
  • wrapperClasses "first scnd third ..."
  • label
  • disabled
  • required
  • after "htmlmarkup will be inserted after this element"
  • before "htmlmarkup will be inserted before this element"
  • checked
  • placeholder
  • Input Specific
  • type
  • value
  • min (for input type range)
  • max (for input type range)
  • checked
  • labelBefore
  • labelAfter
  • Select Specific
  • multiple
  • size
  • options array key => value
  • Textarea Specific
  • text
  • length
  • Form Specific
  • action
  • method
  • enctype

Full Setup

Demo: http://formgen.mstockenberg.de
Get Right Library
$form = new \FormGenerator\Views\FormMaterialize();
Start Form
$form->addElement("Form"); $form->form = "start"; $form->action = "#"; $form->method = "post"; $form->id = "Register";
Selectlists
$form->addElement("Select"); $form->headline = "<h5>Select</h5>"; $form->name = "Register[anrede]"; $form->before = "<div class='row'>"; $form->classes = "icons"; $form->wrapperClasses = "col s4 m4 l4"; $form->label = "Select with Icons left"; $form->options = [ "key" => [ "value" => "Text", "icon" => "picture-95970-1460131169.png", "classes" => "circle left" ], ];
$form->addElement("Select"); $form->name = "Register[anrede]"; $form->classes = "icons"; $form->label = "Select with Icons right"; $form->wrapperClasses = "col s4 m4 l4"; $form->options = [ "key" => [ "value" => "Text", "icon" => "picture-95970-1460131169.png", "classes" => "circle" ], ];
$form->addElement("Select"); $form->name = "Register[anrede]"; $form->wrapperClasses = "col s4 m4 l4"; $form->label = "Normal"; $form->options = [ "herr" => "Herr", "frau" => "Frau" ];
$form->addElement("Select"); $form->name = "Register[anrede]"; $form->classes = "validate"; $form->wrapperClasses = "col s4 m4 l4"; $form->label = "Multiple"; $form->multiple = "multiple"; $form->options = [ "herr" => "Herr", "frau" => "Frau" ];
$form->addElement("Select"); $form->name = "Register[anrede]"; $form->wrapperClasses = "col s4 m4 l4"; $form->classes = "validate"; $form->variant = "optgroup"; $form->label = "Optgroup"; $form->options = [ "Anrede" => [ "herr" => "Herr", "frau" => "Frau" ] ];
$form->addElement("Select"); $form->name = "Register[anrede]"; $form->label = "Browser Default"; $form->wrapperClasses = "col s4 m4 l4"; $form->variant = "browser-default"; $form->id = "default"; $form->after = "</div>"; $form->options = [ "herr" => "Herr", "frau" => "Frau" ];
Input
$form->addElement("Input"); $form->headline = "<h5>Input</h5>"; $form->type = "text"; $form->label = "Normal Textbox"; $form->classes = "validate"; $form->id = "normal";
$form->addElement("Input"); $form->type = "text"; $form->label = "Account Textbox"; $form->classes = "validate"; $form->iconPrefix = "account_circle"; $form->id = "normal";
$form->addElement("Input"); $form->type = "text"; $form->label = "Autocomplete"; $form->classes = "validate autocomplete"; $form->iconPrefix = "textsms"; $form->id = "autocomplete";
$form->addElement("Input"); $form->type = "text"; $form->label = "Phone Textbox"; $form->classes = "validate"; $form->iconPrefix = "phone"; $form->id = "normal";
$form->addElement("Input"); $form->before = "<p style='display: inline-block'> Das ist eine inline Textbox</p>"; $form->type = "text"; $form->label = "Inline Textbox"; $form->classes = "validate"; $form->wrapperClasses = "inline"; $form->id = "normal";
$form->addElement("Input"); $form->type = "email"; $form->label = "E-Mail"; $form->classes = "validate"; $form->error = "Falsch ausgefüllt"; $form->success = "Erfolg!";
$form->addElement("Input"); $form->type = "date"; $form->label = "Date"; $form->classes = "datepicker";
$form->addElement("Input"); $form->type = "text"; $form->label = "Text with Length Count"; $form->classes = "validate"; $form->length = "120"; $form->id = "length";
$form->addElement("Input"); $form->type = "password"; $form->label = "Password"; $form->classes = "validate"; $form->id = "password";
Radio / Checkboxes
$form->addElement("Input"); $form->headline = "<h5>Radio / Checkbox</h5>"; $form->type = "switch"; $form->labelBefore = "off"; $form->labelAfter = "on";
$form->addElement("Input"); $form->type = "radio"; $form->classes = "with-gap"; $form->label = "with-gap"; $form->id = "filled";
$form->addElement("Input"); $form->type = "radio"; $form->label = "radio"; $form->id = "asd";
$form->addElement("Input"); $form->type = "checkbox"; $form->classes = "filled-in"; $form->label = "filled-in"; $form->id = "my";
$form->addElement("Input"); $form->type = "checkbox"; $form->label = "checkbox"; $form->id = "check";
Textareas
$form->addElement("Textarea"); $form->headline = "<h5>Textareas</h5>"; $form->label = "Message"; $form->id = "message";
$form->addElement("Textarea"); $form->label = "Message"; $form->id = "message";
$form->addElement("Textarea"); $form->label = "Message"; $form->id = "message-length"; $form->iconPrefix = "mode_edit"; $form->classes = "validate"; $form->length = "120";
Buttons
$form->addElement("Input"); $form->headline = "<h5>Buttons</h5>"; $form->label = "File Upload"; $form->id = "file"; $form->type = "file";
$form->addElement("Input"); $form->value = "Submit"; $form->id = "reset"; $form->wrapperClasses = "row"; $form->classes = "btn col green m12 l12 s12"; $form->type = "reset";
$form->addElement("Input"); $form->value = "Reset"; $form->id = "submit"; $form->wrapperClasses = "row"; $form->classes = "btn col red m12 l12 s12"; $form->type = "submit";
Close Formtag
$form->addElement("Form"); $form->form = "end";
Rendering
$form->Output();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published