PHP Class kartik\builder\TabularForm

Usage: use kartik\form\ActiveForm; use kartik\builder\TabularForm; $form = ActiveForm::begin($options); // $options is array for your form config echo TabularForm::widget([ 'model' => $model, // your model 'form' => $form, 'gridSettings' => [ 'toolbar' => \yii\helpers\Html::submitButton('Submit') ], 'attributes' => [ 'id' => ['type' => TabularForm::INPUT_STATIC], 'name' => ['type' => TabularForm::INPUT_TEXT], 'description' => ['type' => TabularForm::INPUT_TEXT], 'status' => ['type' => TabularForm::INPUT_CHECKBOX, 'enclosedByLabel' => true], ] ]); ActiveForm::end();
Since: 1.0
Author: Kartik Visweswaran ([email protected])
Inheritance: extends BaseForm
显示文件 Open project: kartik-v/yii2-builder Class Usage Examples

Public Properties

Property Type Description
$actionColumn the settings for the action column. If set to false, the action column will not be displayed.
$checkboxColumn the settings for the checkbox column. If set to false, the checkbox column will not be displayed.
$compositeKeySeparator the separator for the composite keys available as an array.
$dataProvider the data provider for the tabular form. This property is required. It must return a valid list of models for rendering the tabular form inputs.
$gridClass the namespaced GridView class name. Defaults to '\kartik\grid\GridView'. Any other class set here must extend from '\kartik\grid\GridView'.
$gridSettings the settings for [[GridView]] widget which will display the tabular form content.
$rowHighlight highlight current row if checkbox is checked.
$rowSelectedClass the CSS class to apply to a row when the row is selected.
$serialColumn the settings for the serial column. If set to false, the serial column will not be displayed.

Protected Properties

Property Type Description
$_columns the grid columns

Public Methods

Method Description
init ( )
run ( )

Protected Methods

Method Description
checkValidSetting ( string $attr, array $settings, string $key, string $type ) Checks if a setting is of valid type and throws exception if not.
getCellValue ( string $attribute, mixed $settings ) : string Generates a cell value.
getStaticInput ( string $type, Model $model, integer $index, array $settings, string $attribute, Formatter $formatter ) : string Generates the static input
initActionColumn ( ) Initializes the action column.
initCheckboxColumn ( ) Initializes the checkbox column.
initColumn ( string $type ) Initializes special columns
initDataColumns ( ) Initializes the data columns.
initOptions ( ) Initializes the widget options
initSerialColumn ( ) Initializes the serial column.
isColumnSet ( string $type ) : boolean Checks if a grid column is set correctly.
registerAssets ( ) Registers the TabularForm widget assets.
renderGrid ( ) : string Render the grid content.
slash ( string $str = '' ) : string Prepends with a back slash if necessary for full namespace validation.

Method Details

checkValidSetting() protected static method

Checks if a setting is of valid type and throws exception if not.
protected static checkValidSetting ( string $attr, array $settings, string $key, string $type )
$attr string the attribute to check
$settings array the attribute settings
$key string the model key
$type string the attribute input type

getCellValue() protected method

Generates a cell value.
protected getCellValue ( string $attribute, mixed $settings ) : string
$attribute string the model attribute.
$settings mixed the configuration for the attribute.
return string the parsed cell value.

getStaticInput() protected method

Generates the static input
protected getStaticInput ( string $type, Model $model, integer $index, array $settings, string $attribute, Formatter $formatter ) : string
$type string the static input type.
$model yii\base\Model the data model.
$index integer the zero based index of the item in dataProvider.
$settings array the attribute settings.
$attribute string the attribute.
$formatter yii\i18n\Formatter the formatter instance.
return string the generated static input.

init() public method

public init ( )

initActionColumn() protected method

Initializes the action column.
protected initActionColumn ( )

initCheckboxColumn() protected method

Initializes the checkbox column.
protected initCheckboxColumn ( )

initColumn() protected method

Initializes special columns
protected initColumn ( string $type )
$type string the grid column type (one of 'serial', 'action', 'checkbox')

initDataColumns() protected method

Initializes the data columns.
protected initDataColumns ( )

initOptions() protected method

Initializes the widget options
protected initOptions ( )

initSerialColumn() protected method

Initializes the serial column.
protected initSerialColumn ( )

isColumnSet() protected method

Checks if a grid column is set correctly.
protected isColumnSet ( string $type ) : boolean
$type string the grid column type (one of 'serial', 'action', 'checkbox').
return boolean whether the column is set.

registerAssets() protected method

Registers the TabularForm widget assets.
protected registerAssets ( )

renderGrid() protected method

Render the grid content.
protected renderGrid ( ) : string
return string the rendered gridview

run() public method

public run ( )

slash() protected static method

Prepends with a back slash if necessary for full namespace validation.
protected static slash ( string $str = '' ) : string
$str string the input string
return string the modified namespace

Property Details

$_columns protected_oe property

the grid columns
protected $_columns

$actionColumn public_oe property

the settings for the action column. If set to false, the action column will not be displayed.
public $actionColumn

$checkboxColumn public_oe property

the settings for the checkbox column. If set to false, the checkbox column will not be displayed.
public $checkboxColumn

$compositeKeySeparator public_oe property

the separator for the composite keys available as an array.
public $compositeKeySeparator

$dataProvider public_oe property

the data provider for the tabular form. This property is required. It must return a valid list of models for rendering the tabular form inputs.
public $dataProvider

$gridClass public_oe property

the namespaced GridView class name. Defaults to '\kartik\grid\GridView'. Any other class set here must extend from '\kartik\grid\GridView'.
public $gridClass

$gridSettings public_oe property

the settings for [[GridView]] widget which will display the tabular form content.
public $gridSettings

$rowHighlight public_oe property

highlight current row if checkbox is checked.
public $rowHighlight

$rowSelectedClass public_oe property

the CSS class to apply to a row when the row is selected.
public $rowSelectedClass

$serialColumn public_oe property

the settings for the serial column. If set to false, the serial column will not be displayed.
public $serialColumn