PHP Class kartik\builder\FormGrid

Usage example: php use kartik\form\ActiveForm; use kartik\builder\FormGrid; $form = ActiveForm::begin($options); // $options is array for your form config echo FormGrid::widget([ 'model' => $model, // your model 'form' => $form, 'autoGenerateColumns' => true, 'rows' => [ [ 'attributes' => [ 'username' => ['type' => Form::INPUT_TEXT, 'options'=> ['placeholder'=>'Enter username...']], 'password' => ['type' => Form::INPUT_PASSWORD], ] ], [ 'attributes' => [ 'first_name' => ['type' => Form::INPUT_TEXT], 'last_name' => ['type' => Form::INPUT_PASSWORD], ] ] ] ]); ActiveForm::end();
Since: 1.0
Author: Kartik Visweswaran ([email protected])
Inheritance: extends yii\bootstrap\Widget
Show file Open project: kartik-v/yii2-builder Class Usage Examples

Public Properties

Property Type Description
$attributeDefaults the default settings that will be applied for all attributes. The array will be configured similar to a single attribute setting value in the Form::$attributes array. One will typically default markup and styling like type, container, prepend, append etc. The settings at the [[Form::$attributes]] level will override these default settings.
$autoGenerateColumns calculate the number of columns automatically based on count of attributes configured in the Form widget. Columns will be created max upto the [[Form::GRID_WIDTH]]. This can be overridden at the [[rows]] level.
$columnOptions the HTML attributes for the grid columns. Applicable only if [[columns]] is greater than 1.
$columnSize the bootstrap device size for rendering each grid column. Defaults to [[SIZE_SMALL]]. This property can be overridden at the [[rows]] level.
$columns the number of columns for each row. This property can be overridden at the [[rows]] level.
$fieldSetOptions the HTML attributes for the field/attributes container. The following options are additionally recognized: - tag: _string_, the HTML tag for the container. Defaults to fieldset. This property can be overridden by options setting at the [[rows]] level.
$form the form instance.
$formName the form name to be provided if not using with model and ActiveForm.
$model the model used for the form.
$rowOptions the HTML attributes for the rows. Applicable only if [[columns]] is greater than 1. This property can be overridden at the [[rows]] level.
$rows the grid rows containing form configuration elements.

Public Methods

Method Description
init ( )
run ( )

Protected Methods

Method Description
getGridOutput ( ) : string Generates the form grid layout.

Method Details

getGridOutput() protected method

Generates the form grid layout.
protected getGridOutput ( ) : string
return string the generated form grid layout.

init() public method

public init ( )

run() public method

public run ( )

Property Details

$attributeDefaults public property

the default settings that will be applied for all attributes. The array will be configured similar to a single attribute setting value in the Form::$attributes array. One will typically default markup and styling like type, container, prepend, append etc. The settings at the [[Form::$attributes]] level will override these default settings.
public $attributeDefaults

$autoGenerateColumns public property

calculate the number of columns automatically based on count of attributes configured in the Form widget. Columns will be created max upto the [[Form::GRID_WIDTH]]. This can be overridden at the [[rows]] level.
public $autoGenerateColumns

$columnOptions public property

the HTML attributes for the grid columns. Applicable only if [[columns]] is greater than 1.
public $columnOptions

$columnSize public property

the bootstrap device size for rendering each grid column. Defaults to [[SIZE_SMALL]]. This property can be overridden at the [[rows]] level.
public $columnSize

$columns public property

the number of columns for each row. This property can be overridden at the [[rows]] level.
public $columns

$fieldSetOptions public property

the HTML attributes for the field/attributes container. The following options are additionally recognized: - tag: _string_, the HTML tag for the container. Defaults to fieldset. This property can be overridden by options setting at the [[rows]] level.
public $fieldSetOptions

$form public property

the form instance.
public $form

$formName public property

the form name to be provided if not using with model and ActiveForm.
public $formName

$model public property

the model used for the form.
public $model

$rowOptions public property

the HTML attributes for the rows. Applicable only if [[columns]] is greater than 1. This property can be overridden at the [[rows]] level.
public $rowOptions

$rows public property

the grid rows containing form configuration elements.
public $rows