我真的想渲染一个复选框列表,之前从未尝试过它,所以我遇到了问题,我试图渲染每个列或属性的所有复选框,这是动作控制器:
public function actionCreate()
{
$model=new Parametro;
$variable = file_get_contents('protected\column.txt');
$vars = explode(' ', $variable);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Parametro']))
{
$model->attributes=$_POST['Parametro'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
'variable'=>$vars,
));
}
这是带有另一种方法的模型
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
$variable = file_get_contents('protected\column.txt');
return array(
array('parametro_id', 'required'),
array('parametro_id', 'numerical', 'integerOnly'=>true),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, parametro_id', 'safe', 'on'=>'search'),
array($variable, 'safe', 'on'=>'search'),
);
}
public function generateAttributeLabel($variable = null)
{
if($variable)
{
$variable = file_get_contents('protected\column.txt');
}
return $variable;
}
public function attributeLabels()
{
return array(
'id' => 'ID',
'parametro_id' => 'Parametro',
);
}
我试图制作复选框列表的表单
<div>
<?php echo $form->checkboxList($model, $variable, array(0 => 1)); ?>
</div>
和文件的内容,如果你问
lololo trying
有一些列是自动生成的,我将它们的名称存储在这个文件中,用空格分隔,一切似乎都很好,直到我到达表单上的复选框列表,它给了我类似 strpos() 之类的错误,我该怎么做此复选框用于呈现并将 1 个数据保存到由特定列检查的那些?