Cactiveform Checkboxlist

im really trying to render a checkboxlist, never did make a try on it before so im having problems with it, im trying to render all the checkboxes foreach column or attribute made, this is the action controller:


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,

        ));

    }

this is the model with another some methods


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',

    );

}

the form where im trying to make the checkboxlist


<div>

        <?php echo $form->checkboxList($model, $variable, array(0 => 1)); ?>

</div>

and the content of the file if you ask


lololo trying

the are some columns that are being generated automatically and im storing their names on this file separated by spaces, everything seems to be fine until i got to the checkboxlist on form, it gives me error like strpos() or something, how can i make this checkbox to render and to save 1 data to thoses who are checked by specific columns?

Hi nosthertus,

It’s kinda hard to figure out what went wrong, but I guess it will help if you put here the complete error message instead of “error like strpos() or something”.