class BootstrapRenderer implements IFormRenderer

Converts a Form into Bootstrap 4 HTML output.

Traits

SmartObject

Constants

defaultLabelColumns

defaultControlColumns

Properties

string $gridBreakPoint Bootstrap grid breakpoint for side-by-side view. Default is 'sm'. NULL means not to use a breakpoint
protected BootstrapForm $form
protected int $labelColumns
protected int $controlColumns
int $mode
bool $groupHidden if true, hidden fields will be grouped at the end. If false, hidden fields are placed where they were added. Default is true.

Methods

__construct(int $mode = RenderMode::VerticalMode)

BootstrapRenderer constructor.

attachForm( Form $form)

Sets the form for which to render. Used only if a specific function of the renderer must be executed outside of render(), such as during assisted manual rendering.

Html |null
configElem($config, $el = NULL)

Turns configuration or and existing element and configures it appropriately

getConfig()

No description

getConfigOverride()

No description

string
getGridBreakPoint()

No description

setGridBreakPoint(string $gridBreakPoint)

No description

int
getMode()

Returns render mode

bool
isGroupHidden()

No description

setGroupHidden(bool $groupHidden)

No description

string
render( Form $form, null $mode = NULL)

Provides complete form rendering.

string
renderBegin()

Renders form begin.

string
renderBody()

Renders form body.

string
renderControl( IControl $control)

Renders 'control' part of visual row of controls.

string
renderControls( Container | ControlGroup $parent)

Renders group of controls.

string
renderEnd()

Renders form end.

Html
renderLabel( IControl $control)

Renders 'label' part of visual row of controls.

string
renderPair( IControl $control)

Renders single visual row.

setColumns(int $label, int|null $control = NULL)

Set how many of Bootstrap rows shall the label and control occupy

setMode(int $renderMode)

Sets render mode

array
fetchConfig(string $key)

Fetch config tailored for current render mode

Html |null
getElem($key, array ...$additionalKeys)

Get element based on its first-level key

Html |null
renderDescription( IControl $control)

Renders control description (help text)

Html |null
renderFeedback( BaseControl |null $control = NULL)

Renders valid or invalid feedback of form or control

Details

at line 68
__construct(int $mode = RenderMode::VerticalMode)

BootstrapRenderer constructor.

Parameters

int $mode

at line 78
attachForm( Form $form)

Sets the form for which to render. Used only if a specific function of the renderer must be executed outside of render(), such as during assisted manual rendering.

Parameters

Form $form

at line 89
Html |null configElem($config, $el = NULL)

Turns configuration or and existing element and configures it appropriately

Parameters

$config array|string top-level config key
$el Html|null elem to config.

Return Value

Html |null

at line 165
getConfig()

at line 229
getConfigOverride()

at line 268
string getGridBreakPoint()

Return Value

string

at line 277
BootstrapRenderer setGridBreakPoint(string $gridBreakPoint)

Parameters

string $gridBreakPoint null for none

Return Value

BootstrapRenderer

at line 289
int getMode()

Returns render mode

Return Value

int

See also

at line 298
bool isGroupHidden()

Return Value

bool

See also

at line 308
BootstrapRenderer setGroupHidden(bool $groupHidden)

Parameters

bool $groupHidden

Return Value

BootstrapRenderer

See also

at line 321
string render( Form $form, null $mode = NULL)

Provides complete form rendering.

Parameters

Form $form
null $mode

Return Value

string

at line 338
string renderBegin()

Renders form begin.

Return Value

string

at line 372
string renderBody()

Renders form body.

Return Value

string

at line 441
string renderControl( IControl $control)

Renders 'control' part of visual row of controls.

Parameters

IControl $control

Return Value

string

at line 461
string renderControls( Container | ControlGroup $parent)

Renders group of controls.

Parameters

Container | ControlGroup $parent

Return Value

string

at line 503
string renderEnd()

Renders form end.

Return Value

string

at line 513
Html renderLabel( IControl $control)

Renders 'label' part of visual row of controls.

Parameters

IControl $control

Return Value

Html

at line 541
string renderPair( IControl $control)

Renders single visual row.

Parameters

IControl $control

Return Value

string

at line 583
setColumns(int $label, int|null $control = NULL)

Set how many of Bootstrap rows shall the label and control occupy

Parameters

int $label
int|null $control

at line 598
setMode(int $renderMode)

Sets render mode

Parameters

int $renderMode RenderMode

See also

at line 608
protected array fetchConfig(string $key)

Fetch config tailored for current render mode

Parameters

string $key first-level key of $this->config

Return Value

array

at line 626
protected Html |null getElem($key, array ...$additionalKeys)

Get element based on its first-level key

Parameters

$key
array ...$additionalKeys config will be overridden in this order

Return Value

Html |null

at line 643
protected Html |null renderDescription( IControl $control)

Renders control description (help text)

Parameters

IControl $control

Return Value

Html |null

at line 670
protected Html |null renderFeedback( BaseControl |null $control = NULL)

Renders valid or invalid feedback of form or control

Parameters

BaseControl |null $control null = whole form

Return Value

Html |null