FormController
class FormController extends ControllerAction
Form Controller Class
Traits
Widget Maker Trait Class
Extension trait
Constants
CONTEXT_CREATE |
|
CONTEXT_EDIT |
|
CONTEXT_PREVIEW |
|
Properties
string | $configPath | from ConfigMaker | |
protected | $configFileExtension | from ConfigMaker | |
array | $vars | from ViewMaker | |
array | $viewPath | from ViewMaker | |
array | $layoutPath | from ViewMaker | |
array | $partialPath | from ViewMaker | |
string | $layout | from ViewMaker | |
bool | $suppressLayout | from ViewMaker | |
protected | $viewFileExtension | from ViewMaker | |
static protected array | $extensionCallbacks | from ExtensionTrait | |
static string | $extendableStaticCalledClass | from ExtensionTrait | |
protected | $extensionHidden | from ExtensionTrait | |
protected AdminController|FormController | $controller | ||
protected array | $config | from ControllerAction | |
protected | $requiredProperties | ||
array | $formConfig | Define controller list configuration array. |
|
protected Form | $formWidget | ||
protected BaseWidget | $toolbarWidget | ||
protected array | $requiredConfig | ||
protected string | $context | ||
protected Model | $model | ||
protected Model | $request | ||
protected array | $modelsToSave |
Methods
Reads the contents of the supplied file and applies it to this object.
Reads the contents of the supplied file and applies it to this object.
Merges two configuration sources, either prepared or not, and returns them as a single configuration object.
Locates a file based on it's definition. If the file starts with the ~ symbol it will be returned in context of the application base path, otherwise it will be returned in context of the config path.
Guess the package path for the called class.
Guess the package path from a specified class.
Guess the package path from a specified class.
Render a layout.
Render a partial file contents located in the views or partial folder.
Includes a file path using output buffering.
Makes a widget object with the supplied configuration ex. model config
Makes a form widget object with the supplied form field and widget configuration.
Helper method for ::extend()
static method
FormController constructor.
Sets the widget configuration values
Get the widget configuration values.
Protects a public method from being available as an controller method.
Finds a Model record by its primary identifier, used by edit actions. This logic can be changed by overriding it in the controller.
Creates a new instance of a form model. This logic can be changed by overriding it in the controller.
Called before the form is refreshed, should return an array of additional save data.
Called when the form is refreshed, giving the opportunity to modify the form fields.
Called after the form is refreshed, should return an array of additional result parameters.
Extend supplied model used by create and edit actions, the model can be altered by overriding it in the controller.
Extend the query used for finding the form model. Extra conditions can be applied to the query, for example, $query->withTrashed();
Static helper for extending form fields.
Prepares common form data
No description
No description
No description
No description
No description
No description
Render the form.
Returns the model initialized by this form behavior.
Returns the form context from the postback or configuration.
No description
Internal method, prepare the form model object
Returns a Redirect object based on supplied context and parses the model primary key.
Internal method, returns a redirect URL from the config based on supplied context. Otherwise the default redirect is used.
No description
Sets a data collection to a model attributes, relations will also be set.
No description
No description
Details
in
ConfigMaker at line 27
array
loadConfig(array $configFile = [], array $requiredConfig = [], null $index = null)
Reads the contents of the supplied file and applies it to this object.
in
ConfigMaker at line 46
array
makeConfig(string|array $configFile, array $requiredConfig = [])
Reads the contents of the supplied file and applies it to this object.
in
ConfigMaker at line 97
array
mergeConfig($configLeft, $configRight)
Merges two configuration sources, either prepared or not, and returns them as a single configuration object.
in
ConfigMaker at line 116
string
getConfigPath(string $fileName, mixed $configPath = null)
Locates a file based on it's definition. If the file starts with the ~ symbol it will be returned in context of the application base path, otherwise it will be returned in context of the config path.
in
ConfigMaker at line 154
string
guessConfigPath(string $suffix = '')
Guess the package path for the called class.
in
ConfigMaker at line 169
string
guessConfigPathFrom(string $class, string $suffix = '')
Guess the package path from a specified class.
in
ViewMaker at line 50
getViewPath($view, $viewPath = null)
No description
in
ViewMaker at line 78
guessViewFileExtension($path)
No description
in
ViewMaker at line 98
string
guessViewPath(string $suffix = '', bool $isPublic = false)
Guess the package path from a specified class.
in
ViewMaker at line 119
mixed
makeLayout(string $name = null, array $vars = [], bool $throwException = true)
Render a layout.
in
ViewMaker at line 147
string
makeView(string $view)
Loads a view with the name specified.
Applies layout if its name is provided by the parent object. The view file must be situated in the views directory, and has the extension "htm" or "php".
in
ViewMaker at line 171
mixed
makePartial(string $partial, array $vars = [], bool $throwException = true)
Render a partial file contents located in the views or partial folder.
in
ViewMaker at line 199
string
makeFileContent(string $filePath, array $extraParams = [])
Includes a file path using output buffering.
Ensures that vars are available.
in
ViewMaker at line 235
compileFileContent($filePath)
No description
in
ViewMaker at line 256
protected void
handleViewException(Exception $e, int $obLevel)
Handle a view exception.
in
ViewMaker at line 271
protected array
gatherViewData($data)
Get the data bound to the view instance.
in
WidgetMaker at line 24
BaseWidget
makeWidget(string $class, array $widgetConfig = [])
Makes a widget object with the supplied configuration ex. model config
in
WidgetMaker at line 47
BaseFormWidget
makeFormWidget(string $class, mixed $fieldConfig = [], array $widgetConfig = [])
Makes a form widget object with the supplied form field and widget configuration.
in
ExtensionTrait at line 32
extensionApplyInitCallbacks()
No description
in
ExtensionTrait at line 51
static void
extensionExtendCallback(callable $callback)
Helper method for ::extend()
static method
in
ExtensionTrait at line 64
protected
extensionHideField($name)
No description
in
ExtensionTrait at line 69
protected
extensionHideMethod($name)
No description
in
ExtensionTrait at line 74
extensionIsHiddenField($name)
No description
in
ExtensionTrait at line 79
extensionIsHiddenMethod($name)
No description
in
ExtensionTrait at line 84
static
getCalledExtensionClass()
No description
at line 97
__construct(Controller $controller)
FormController constructor.
in
ControllerAction at line 65
setConfig(string|array $config, array $required = [])
Sets the widget configuration values
in
ControllerAction at line 78
mixed
getConfig(string $name = null, mixed $default = null)
Get the widget configuration values.
in
ControllerAction at line 103
protected
hideAction($methodName)
Protects a public method from being available as an controller method.
in
FormExtendable at line 13
formValidate($model, $form)
Called to validate create or edit form.
in
FormExtendable at line 20
formBeforeSave($model)
Called before the creation or updating form is saved.
in
FormExtendable at line 27
formAfterSave($model)
Called after the creation or updating form is saved.
in
FormExtendable at line 34
formBeforeCreate($model)
Called before the creation form is saved.
in
FormExtendable at line 41
formAfterCreate($model)
Called after the creation form is saved.
in
FormExtendable at line 48
formBeforeUpdate($model)
Called before the updating form is saved.
in
FormExtendable at line 55
formAfterUpdate($model)
Called after the updating form is saved.
in
FormExtendable at line 62
formAfterDelete($model)
Called after the form model is deleted.
in
FormExtendable at line 75
formFindModelObject(string $recordId)
Finds a Model record by its primary identifier, used by edit actions. This logic can be changed by overriding it in the controller.
in
FormExtendable at line 108
formCreateModelObject()
Creates a new instance of a form model. This logic can be changed by overriding it in the controller.
in
FormExtendable at line 120
void
formExtendFieldsBefore(Form $host)
Called before the form fields are defined.
in
FormExtendable at line 131
void
formExtendFields(Form $host, $fields)
Called after the form fields are defined.
in
FormExtendable at line 143
array
formExtendRefreshData(Form $host, array $saveData)
Called before the form is refreshed, should return an array of additional save data.
in
FormExtendable at line 155
array
formExtendRefreshFields(Form $host, array $fields)
Called when the form is refreshed, giving the opportunity to modify the form fields.
in
FormExtendable at line 167
array
formExtendRefreshResults(Form $host, array $result)
Called after the form is refreshed, should return an array of additional result parameters.
in
FormExtendable at line 179
formExtendModel(Model $model)
Extend supplied model used by create and edit actions, the model can be altered by overriding it in the controller.
in
FormExtendable at line 191
void
formExtendQuery(Builder $query)
Extend the query used for finding the form model. Extra conditions can be applied to the query, for example, $query->withTrashed();
in
FormExtendable at line 195
formExtendConfig($formConfig)
No description
in
FormExtendable at line 206
static void
extendFormFields(callable $callback)
Static helper for extending form fields.
at line 145
void
initForm(Model $model, null $context = null)
Prepare the widgets used by this action
at line 217
protected
prepareVars($model)
Prepares common form data
at line 224
create($context = null)
No description
at line 240
create_onSave($context = null)
No description
at line 274
edit($context = null, $recordId = null)
No description
at line 290
edit_onSave($context = null, $recordId = null)
No description
at line 324
edit_onDelete($context = null, $recordId = null)
No description
at line 346
preview($context = null, $recordId = null)
No description
at line 373
string
renderForm(array $options = [])
Render the form.
at line 392
Model
getFormModel()
Returns the model initialized by this form behavior.
at line 401
string
getFormContext()
Returns the form context from the postback or configuration.
at line 409
protected
setFormTitle($default)
No description
at line 425
protected Model
createModel()
Internal method, prepare the form model object
at line 440
Redirect
makeRedirect(string $context = null, Model $model = null)
Returns a Redirect object based on supplied context and parses the model primary key.
at line 472
protected string
getRedirectUrl(string $context = null)
Internal method, returns a redirect URL from the config based on supplied context. Otherwise the default redirect is used.
at line 486
protected
prepareModelsToSave($model, $saveData)
No description
at line 503
protected void
setModelAttributes(Model $model, array $saveData)
Sets a data collection to a model attributes, relations will also be set.
at line 528
protected
validateFormRequest($model)
No description
at line 541
protected
resolveFormRequest($requestClass)
No description