php yii 表单title,Yii2.0-ActiveForm表单结构自定义教程
應用實例:use?yii\bootstrap\ActiveForm;
$form?=?ActiveForm::begin(['layout'?=>?'horizontal']);
//?隱藏form的標簽
echo?$form->field($model,?'demo',?[
'inputOptions'?=>?[
'placeholder'?=>?$model->getAttributeLabel('demo'),
],
])->label(false);
//?內聯?radio?list
echo?$form->field($model,?'demo')->inline()->radioList($items);
//水平模式控制規模大小
echo?$form->field($model,?'demo',?[
'horizontalCssClasses'?=>?[
'wrapper'?=>?'col-sm-2',
]
]);
//?除了'default(默認)'?布局?你還可以用?'template'?制定特定的布局:
echo?$form->field($model,?'demo',?[
'template'?=>?'{label}?
{input}{error}{hint}']);
//?輸入框模板配置
echo?$form->field($model,?'demo',?[
'inputTemplate'?=>?'
@{input}',]);
ActiveForm::end();
相關ActiveFrom資料: \yii\bootstrap\ActiveForm
相關bootstrap資料: http://getbootstrap.com/css/#forms
ActiveForm表單參數:
[[\yii\widgets\ActiveField]]. 加強版的Bootstrap 3
這個類添加了一些有用的功能到 [[\yii\widgets\ActiveField|ActiveField]] 在不同的形式布局中提供各種bootstrap3的表單域:
- [[inputTemplate]] 是一個用來呈現復雜輸入的可選模板,例如輸入組
- [[horizontalCssClasses]] 以橫向形式定義了css網絡格以增加標簽,包裝和錯誤提示
- [[inline]]/[[inline()]] 被用于提供內聯的[[checkboxList()]] 和[[radioList()]]
- [[enableError]] 被設置為‘false’以禁用錯誤
- [[enableLabel]] 被設置為`false` 以禁用標簽
- [[label()]] 和boolean值一起使用,來啟用和禁用標簽
也有一些新的占位符,你可以用在 [[template]] 結構中:
- `{beginLabel}`: 開始標簽
- `{labelTitle}`: 標簽的標題,和 `{beginLabel}`/`{endLabel}`一起使用
- `{endLabel}`: 結束標簽
- `{beginWrapper}`: 開始包裝標簽
- `{endWrapper}`: 關閉包裝標簽
包裝標簽僅用于某些布局和表單元素.
請注意,某些元素使用了 [[template]]的輕微不同的默認值和其他選項.
你可以重寫這些預定義模板復選框, radio buttons, checkboxLists和 radioLists 在 [[\yii\widgets\ActiveForm::fieldConfig|fieldConfig]] 的
[[\yii\widgets\ActiveForm]]:
- [[checkboxTemplate]] 在默認布局復選框模板
- [[radioTemplate]] 默認布局中的radio button模板
- [[horizontalCheckboxTemplate]] 水平布局的 checkboxes模塊
- [[horizontalRadioTemplate]] 水平布局的 radio buttons 模塊
- [[inlineCheckboxListTemplate]] 內聯的 checkboxLists模塊
- [[inlineRadioListTemplate]] 內聯的 radioLists模塊
總結
以上是生活随笔為你收集整理的php yii 表单title,Yii2.0-ActiveForm表单结构自定义教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: elasticsearch基本查询三(英
- 下一篇: Java的不同版本:J2SE、J2EE、