コード例 #1
0
 /**
  * Returns a string with list items <li> of associated students
  *
  * @param $name Represents widget's name
  * @param array $student_ids  array of integer representing student ids
  * @return string
  */
 public static function getAssociatedStudentsList($name, $student_ids, $fixed_values = array())
 {
     $ret = '';
     $criteria = new Criteria();
     $criteria->addAscendingOrderByColumn(PersonPeer::LASTNAME);
     $criteria->addAnd(StudentPeer::ID, $student_ids, Criteria::IN);
     $students = StudentPeer::doSelectJoinPerson($criteria);
     $name .= "[]";
     foreach ($students as $s) {
         $fixed = in_array($s->getId(), $fixed_values);
         $checkbox = $fixed ? "&nbsp;" : "<input type='checkbox' name='checkbox_{$name}' />";
         $fixed_class = $fixed ? 'fixed' : '';
         $hidden_widget = new sfWidgetFormInputHidden();
         $hidden = $hidden_widget->render($name, $s->getId());
         $ret .= "<li class='associated_student {$fixed_class}'><span>{$checkbox}</span>{$s} {$hidden}</li>";
     }
     return $ret;
 }