Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 66 lines (57 sloc) 1.88 kb
6e4107d @lucaswxp readme - adding goal
authored
1 Goal
2 ============
3 This library has the goal of make simple the creation and population of HTML forms
4
f2b3b23 @lucaswxp adding API link to readme
authored
5 API
6 ============
7 http://pelegrinodev.com/repos/fg/api/
8
740d1db @lucaswxp changing readme
authored
9 Usage example
10 =============
11
653e9de @lucaswxp added submit input type and readme updated
authored
12 ```php
740d1db @lucaswxp changing readme
authored
13 <?php
fdb1dc3 @lucaswxp initializing project
authored
14 require_once 'fg/load.php';
15
16 $form = Form::create('formaction.php'); // form action attribute
17 $form
18 ->add(Form::text('user[name]')->setLabel('Username: ')) // adds a text field with a name and wrapped with a div tag
19 ->add(Html::tag('br')) // adds a non-field object
20 ->add(Form::password('user[password]')->setLabel('Password: ')) // adds a password field with a name
21 ->add(Html::tag('br'))
22 ->add(
23 Form::radios('gender') // create a collection of radio buttons
24 ->add('M', 'Male') // add a radio with value "M" and label "Male"
25 ->add('F', 'Female') // add a radio with value "F" and label "Female"
26 )
65c237e @lucaswxp changing readme
authored
27 ->add('<ul>')
fdb1dc3 @lucaswxp initializing project
authored
28 ->add(
6e4107d @lucaswxp readme - adding goal
authored
29 Form::checkboxes('interests[]') // create a collection of checkboxeseaa
fdb1dc3 @lucaswxp initializing project
authored
30 ->add('games', 'Games')
31 ->add('animes', 'Animes')
32 ->add('o_thing', 'Other things')
33 ->setWrapper(Html::tag('li')->setClass('li-item')) // changes the wrapper, default is div
34 )
65c237e @lucaswxp changing readme
authored
35 ->add('</ul>')
fdb1dc3 @lucaswxp initializing project
authored
36 ->add(
37 Form::select('songs[]')->setMultiple(true) // create a select multiple input
38 ->add('sth', 'Stairway to Heaven')
39 ->add('nem', 'Nothing Else Matters')
40 ->add('fb', 'Free bird')
41 ->add('others', 'Others')
42 )
43 ->add(
44 Form::checkbox('newsletter')->setLabel('Receive newsletter? ') // create a single checkbox
45 );
46
47 echo $form; // or echo $form->render()
48 ```
740d1db @lucaswxp changing readme
authored
49
fdb1dc3 @lucaswxp initializing project
authored
50 If you wanna populate your form, you can use the populate method:
740d1db @lucaswxp changing readme
authored
51
fdb1dc3 @lucaswxp initializing project
authored
52
653e9de @lucaswxp added submit input type and readme updated
authored
53 ```php
c7350ba @lucaswxp added submit input type and readme updated
authored
54 <?php
fdb1dc3 @lucaswxp initializing project
authored
55 $form->populate(array(
56 'user' => array(
57 'name' => 'myuser_name' // user[name] field
58 ),
59 'songs' => array('sth', 'fb') // select these two songs for the field songs[]
60 ...
61 ));
62 ```
63
64 ROADMAP
65 ===============
66 * Write documentation
Something went wrong with that request. Please try again.