Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
How to check the checkboxes if id is in database Yii?

I have created a checkBoxList() in a Form. I want to have the checkboxes checked, when the id of the tag in the database matches the values from the generated checkBoxList(). However, I was oblivious to the fact of how to compare the id from the server and the value (which is the ID) of the frontend.

This is what I have in the form.

<div class ="col-md-2">
    <?php echo $form->labelEx($tag,'tag'); ?>
    <?php echo $form->checkBoxList($tag, 'tag', CHtml::listData(Tag::model()->findAll(), 'idtag', 'tag'), array('id'=>'updateTag', 'name'=>'updateTag')); ?>
</div>

When using the code below, I can get the exact ID of the tags I need.

    $criteria = new CDbCriteria();
    $criteria->addCondition('t.fk_iddashboard ='."$model->iddashboard");
    $dashboardHasTag = DashboardHasTag::model()->findAll($criteria);

        foreach ($dashboardHasTag as $key => $value) {
            $idTag = $value->fk_idtag;
        }

Any advice on how to make it work?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!