Form
extends SimpleModel
in package
Uses
FWEdit, MakeGuard
A class implementing a RedBean model for Form beans
Tags
Table of Contents
- $attributes : array<, string>
- $editfields : array<, array<, bool>>
- $flags : array<, mixed>
- $methods : array<, string>
- $optgroup : bool
- add() : OODBBean
- Add a new form, called when adding a new form via ajax
- edit() : array<, mixed>
- Handle a form edit
- fields() : array<, string>
- Return the form's fields
- guard() : string
- Return the CSRFGuard inputs for inclusion in a form;
- method() : string
- Return the form's method
- name() : string
- Return the form name
- render() : string
- Render a form
- resequence() : void
- Resequence the fields so that they are all multiples of 10
- sequence() : array<, array<, string>>
- Return the form's fields by sequence
- startEdit() : void
- Setup for an edit
- view() : void
- View a form
- dofields() : array<, string>
- Handle editing of beans
- doOption() : string
- handle an option
- mkOption() : string
- Make an option tag
Properties
$attributes
private
static array<, string>
$attributes
= ['type', 'class', 'name', 'placeholder']
Attributes for inputs
Tags
$editfields
private
static array<, array<, bool>>
$editfields
= [
'name' => [TRUE, FALSE],
// [NOTEMPTY, CHECK/RADIO]
'action' => [TRUE, FALSE],
'method' => [TRUE, FALSE],
'idval' => [FALSE, FALSE],
'class' => [FALSE, FALSE],
'multipart' => [FALSE, TRUE],
]
Key is name of field and the array contains flags for checks
Tags
$flags
private
static array<, mixed>
$flags
= ['checked' => ['Checked', TRUE, 0x1], 'disabled' => ['Disabled', FALSE, 0x2], 'multiple' => ['Multiple', TRUE, 0x4], 'readonly' => ['Readonly', FALSE, 0x8], 'required' => ['Required', FALSE, 0x10]]
The kinds of flags that fields can have
$methods
private
static array<, string>
$methods
= ['', 'GET', 'POST']
METHOD options for forms
$optgroup
private
bool
$optgroup
= FALSE
flag to indicate inside optgroup - nested optgroups are NOT supported (at the moment)
Methods
add()
Add a new form, called when adding a new form via ajax
public
static add(Context $context) : OODBBean
Parameters
- $context : Context
-
The context object
Tags
Return values
OODBBean —edit()
Handle a form edit
public
edit(Context $context) : array<, mixed>
Parameters
- $context : Context
-
The context object
Tags
Return values
array<, mixed> —fields()
Return the form's fields
public
fields() : array<, string>
Return values
array<, string> —guard()
Return the CSRFGuard inputs for inclusion in a form;
public
guard() : string
Return values
string —method()
Return the form's method
public
method() : string
Return values
string —name()
Return the form name
public
name() : string
Return values
string —render()
Render a form
public
render([array<, mixed> $values = [] ][, bool $noform = FALSE ]) : string
Parameters
- $values : array<, mixed> = []
-
Values to enter into form
- $noform : bool = FALSE
-
If TRUE then do not put out the
tags - useful when building forms in parts
Return values
string —resequence()
Resequence the fields so that they are all multiples of 10
public
resequence() : void
Remember that some items deliberatley share sequence numbers!
Tags
Return values
void —sequence()
Return the form's fields by sequence
public
sequence() : array<, array<, string>>
Some fields deliberately share sequence numbers (e.g. checkboxes in a row)
Return values
array<, array<, string>> —startEdit()
Setup for an edit
public
startEdit(Context $context, array<, string> $rest) : void
Parameters
- $context : Context
-
The context object
- $rest : array<, string>
-
Not used here at the moment
Tags
Return values
void —view()
View a form
public
view(Context $context, array<, string> $rest) : void
Parameters
- $context : Context
- $rest : array<, string>
Tags
Return values
void —dofields()
Handle editing of beans
private
dofields(AccessBase $fdt) : array<, string>
Parameters
- $fdt : AccessBase
-
The formdata object from the context
Return values
array<, string> —doOption()
handle an option
private
doOption( $option) : string
Parameters
- $option :
Return values
string —mkOption()
Make an option tag
private
mkOption(string $value, string $text, bool $selected, bool $disabled) : string
Parameters
- $value : string
- $text : string
- $selected : bool
- $disabled : bool