| Methods |
protected
|
init(): void
Called when view becomes part of render tree. You can override it but avoid
placing any "heavy processing" here.
Called when view becomes part of render tree. You can override it but avoid
placing any "heavy processing" here.
Overrides
|
#
|
protected
|
initLayout(): void
|
#
|
public
|
setControlsDisplayRules(array $rules = []): $this
Setter for control display rules.
Setter for control display rules.
|
#
|
public
|
setGroupDisplayRules(array $rules = [], string|View $selector = '.atk-form-group'): $this
Set display rule for a group collection.
Set display rule for a group collection.
|
#
|
public
|
setModel(Model $entity, array<int, string>|null $fields = null): void
Associate this view with a model. Do not place any logic in this class, instead take it
to renderView().
Associate this view with a model. Do not place any logic in this class, instead take it
to renderView().
Do not try to create your own "Model" implementation, instead you must be looking for
your own "Persistence" implementation.
Parameters
| $fields |
if null, then all "editable" fields will be added
|
Overrides
|
#
|
public
|
onSubmit(Closure($this): (JsExpressionable|View|string|void) $fx): $this
Adds callback in submit hook.
Adds callback in submit hook.
|
#
|
public
|
getControl(string $name): Control
Return form control associated with the field.
Return form control associated with the field.
Parameters
| $name |
Name of the control
|
|
#
|
public
|
jsError(string $fieldName, string $errorMessage): JsExpressionable
Causes form to generate error.
Causes form to generate error.
|
#
|
public
|
jsSuccess(View|string $success = 'Success', string $subHeader = null, bool $useTemplate = true): JsExpressionable
Causes form to generate success message.
Causes form to generate success message.
Parameters
| $success |
Success message or a View to display in modal
|
| $subHeader |
Sub-header
|
| $useTemplate |
Backward compatibility
|
|
#
|
public
|
addControl(string $name, array<mixed>|Control $control = [], array<mixed> $fieldSeed = []): Control
Add form control into current layout. If no layout, create one. If no model, create blank one.
Add form control into current layout. If no layout, create one. If no model, create blank one.
|
#
|
public
|
addHeader(string|array $title = null): void
Add header into the form, which appears as a separator.
Add header into the form, which appears as a separator.
|
#
|
public
|
addGroup(string|array $title = null): Layout
Creates a group of fields and returns layout.
Creates a group of fields and returns layout.
|
#
|
public
|
controlFactory(Field $field, array<string, mixed> $controlSeed = []): Control
Provided with a Agile Data Model Field, this method have to decide
and create instance of a View that will act as a…
Provided with a Agile Data Model Field, this method have to decide
and create instance of a View that will act as a form-control. It takes
various input and looks for hints as to which class to use:.
- The $seed argument is evaluated
- $f->ui['form'] is evaluated if present
- $f->type is converted into seed and evaluated
- lastly, falling back to Line, Dropdown (based on $reference and $enum)
|
#
|
protected
|
loadPost(): void
Looks inside the POST of the request and loads it into a current model.
Looks inside the POST of the request and loads it into a current model.
|
#
|
protected
|
renderView(): void
View-specific rendering stuff. Feel free to replace this method with
your own. View::renderView contains some logic…
View-specific rendering stuff. Feel free to replace this method with
your own. View::renderView contains some logic that integrates with
Fomantic-UI.
Overrides
|
#
|
protected
|
renderTemplateToHtml(): string
For Form::renderTemplateToHtml() only.
For Form::renderTemplateToHtml() only.
Overrides
|
#
|
public
|
fixOwningFormAttrInRenderedHtml(string $html): string
|
#
|
public
|
setApiConfig(array $config): $this
Set Fomantic-UI Api settings to use with form. A complete list is here:
https://fomantic-ui.com/behaviors/api.html#…
|
#
|
public
|
setFormConfig(array $config): $this
Set Fomantic-UI Form settings to use with form. A complete list is here:
https://fomantic-ui.com/behaviors/form.html#…
|
#
|
public
|
setupAjaxSubmit(): void
|
#
|
| Properties |
public
|
|
$ui = 'form'
|
#
|
public
|
|
$defaultTemplate = 'form.html'
|
#
|
public
|
JsCallback
|
$cb
Callback handling form submission.
Callback handling form submission.
|
#
|
public
|
bool
|
$canLeave = true
Set this to false in order to prevent from leaving page if form is not submit.
Set this to false in order to prevent from leaving page if form is not submit.
|
#
|
public
|
View
|
$formElement
|
#
|
public
|
Layout
|
$layout
A current layout of a form, needed if you call Form->addControl().
A current layout of a form, needed if you call Form->addControl().
|
#
|
public
|
array<string, Control>
|
$controls = []
List of form controls currently registered with this form.
List of form controls currently registered with this form.
|
#
|
public
|
Button|array|false
|
$buttonSave = [Button::class, 'Save', 'class.primary' => true]
Button object, seed or false to not show button at all
Button object, seed or false to not show button at all
|
#
|
public
|
string
|
$successTemplate = 'form-success.html'
|
#
|
public
|
array
|
$controlDisplayRules = []
Collection of field's conditions for displaying a target field on the form.
Collection of field's conditions for displaying a target field on the form.
Specifying a condition for showing a target field required the name of the target field
and the rules to show that target field. Each rule contains a source field's name and a condition for the
source field. When each rule is true, then the target field is show on the form.
Combine multiple rules for showing a field.
ex: ['target' => ['source1' => 'notEmpty', 'source2' => 'notEmpty']]
Show 'target' if 'source1' is not empty AND 'source2' is notEmpty.
Combine multiple condition to the same source field.
ex: ['target' => ['source1' => ['notEmpty', 'number']]
Show 'target' if 'source1 is notEmpty AND is a number.
Combine multiple arrays of rules will OR the rules for the target field.
ex: ['target' => [['source1' => ['notEmpty', 'number']], ['source1' => 'isExactly[5]']
Show "target' if 'source1' is not empty AND is a number
OR
Show 'target' if 'source1' is exactly 5.
|
#
|
public
|
string
|
$controlDisplaySelector = '.field'
|
#
|
public
|
array
|
$apiConfig = []
Use this apiConfig variable to pass API settings to Fomantic-UI in .api().
Use this apiConfig variable to pass API settings to Fomantic-UI in .api().
|
#
|
public
|
array
|
$formConfig = []
Use this formConfig variable to pass settings to Fomantic-UI in .from().
Use this formConfig variable to pass settings to Fomantic-UI in .from().
|
#
|
protected
|
array<string, array>
|
$typeToControl = [
'boolean' => [Checkbox::class],
'text' => [Textarea::class],
'datetime' => [Calendar::class, 'type' => 'datetime'],
'date' => [Calendar::class, 'type' => 'date'],
'time' => [Calendar::class, 'type' => 'time'],
'atk4_money' => [Money::class],
]
|
#
|