|
1 | 1 | # Methods |
2 | 2 |
|
| 3 | +This pages contains an overview of the structural methods that you can use to build a form. |
| 4 | + |
| 5 | +All structural methods return a self-reference allowing to chain the method calls. |
| 6 | + |
3 | 7 | ## Form |
4 | 8 |
|
5 | | -The Form object has the following data methods: |
| 9 | +Is created by: |
6 | 10 |
|
7 | | -- **fill**: Fill the form with an array of data (e.g. $_POST) |
8 | | -- **extract**: Extract the filled in form values |
9 | | -- **validate**: Validate the form and add errors where needed |
10 | | -- **addErrors**: Add custom errors (after validation) |
11 | | -- **render**: Output the form with or without root element |
| 11 | +- **form**: Create a Form |
12 | 12 |
|
13 | | -And the following structure building methods: |
| 13 | +And has the following structure building methods: |
14 | 14 |
|
15 | 15 | - **fieldsets**: Add multiple Fieldset elements |
16 | 16 | - **fieldset**: Add a single Fieldset element |
17 | 17 | - **fields**: Add multiple Field elements |
18 | 18 | - **field**: Add a single Field element |
| 19 | +- **header**: Add a single Header element |
| 20 | + |
| 21 | +Instead of: |
| 22 | + |
| 23 | + $form = E::form()->fields([...]); |
| 24 | + |
| 25 | +You can use: |
| 26 | + |
| 27 | + $form = E::form([...]); |
| 28 | + |
| 29 | +as a shortcut. |
| 30 | + |
| 31 | +## Fieldset (optional) |
| 32 | + |
| 33 | +Is created by: |
| 34 | + |
| 35 | +- **fieldset**: Create a Fieldset |
| 36 | + |
| 37 | +And has the following structure building methods: |
| 38 | + |
| 39 | +- **legend**: Add a Legend element to the Fieldset |
| 40 | +- **header**: Add a single Header element |
| 41 | +- **fields**: Add multiple Field elements |
| 42 | +- **field**: Add a single Field element |
| 43 | + |
| 44 | +NB: Unless required you should use "fields", "field" and "header" on Form instead. |
| 45 | + |
| 46 | +## Field |
| 47 | + |
| 48 | +Is created by: |
| 49 | + |
| 50 | +- **field**: Create a Field |
| 51 | + |
| 52 | +And has the following structure building methods: |
| 53 | + |
| 54 | +- **label**: Set the label for the Field |
| 55 | +- **control**: Set the control for the Field |
| 56 | +- **validators**: Set the validators for the Field |
| 57 | + |
| 58 | +Instead of: |
| 59 | + |
| 60 | + $form = E::field()->control($control)->label($label)->validators([$validator]); |
| 61 | + |
| 62 | +You can use: |
| 63 | + |
| 64 | + $form = E::field($control,$label,[$validator]); |
| 65 | + |
| 66 | +as a shortcut. |
| 67 | + |
| 68 | +## Input |
| 69 | + |
| 70 | +Is created by: |
| 71 | + |
| 72 | +- **text**: Create a text Input |
| 73 | +- **password**: Create a password Input |
| 74 | +- **email**: Create an email Input |
| 75 | +- **number**: Create a number Input |
| 76 | +- **submit**: Create a submit Input |
| 77 | + |
| 78 | +And has the following structure building methods: |
| 79 | + |
| 80 | +- **type**: Set the type of the Input |
| 81 | +- **name**: Set the name of the Input |
| 82 | +- **value**: Set the value of the Input |
| 83 | +- **placeholder**: Set the placeholder of the Input |
| 84 | + |
| 85 | +Instead of: |
| 86 | + |
| 87 | + $form = E::text()->name($name)->placeholder($placeholder); |
| 88 | + $form = E::submit()->value($value); |
19 | 89 |
|
20 | | -## Fieldset |
| 90 | +You can use: |
21 | 91 |
|
| 92 | + $form = E::text($name,$placeholder); |
| 93 | + $form = E::submit($value); |
22 | 94 |
|
| 95 | +as a shortcut. |
0 commit comments