/** * Returns options for the related model multiple select * @param string $model * @return string options for relate model multiple select * @since 1.0 */ public function related_opts($model) { $relatedPKs = Assignment::extractPkValue($model->assignments); $options = ''; $categories = GxHtml::listDataEx(Assignment::model()->findAllAttributes(null, true)); foreach ($categories as $value => $text) { if (!$model->isNewRecord) { in_array($value, $relatedPKs) ? $options .= '<option selected="selected" value=' . $value . '>' . $text . '</option>\\n' : ($options .= '<option value=' . $value . '>' . $text . '</option>\\n'); } else { $options .= '<option value=' . $value . '>' . $text . '</option>\\n'; } } echo $options; }