sfWidgetFormDoctrineChoice
을 사용하여 양식에서 선택 요소를 작성합니다. 첫 번째 위젯sfWidgetFormDoctrineChoice : 버그, 오류 또는 무엇?
// Fill maquinaemisorid
$this->widgetSchema['maquinaemisorid'] = new sfWidgetFormDoctrineChoice(array('model' => 'SdrivingMaquina', 'add_empty' => 'Seleccione una Máquina', 'table_method' => 'fillChoice'));
// Fill idoperador
$this->widgetSchema['idoperador'] = new sfWidgetFormDoctrineChoice(array('model' => 'SdrivingOperador', 'add_empty' => 'Seleccione un Operador', 'table_method' => 'fillChoice'));
// Fill idturno
$this->widgetSchema['idturno'] = new sfWidgetFormDoctrineChoice(array('model' => 'SdrivingTurno', 'add_empty' => 'Seleccione un Turno', 'table_method' => 'fillChoice'));
모두 괜찮 및 값이어야한다로하지만 1 초 동안 DB에서 가져온 세 번째가 작동하지 : 이것은 내가 사용하는 방법입니다. 모든 위젯에서 fillChoice
메서드를 호출하고 있습니다. table_method
. 단지 각 클래스에 사용되는 테이블을 변경
SdrivingMaquinaTable.class.php
public function fillChoice() {
$id_empresa = sfContext::getInstance()->getUser()->getGuardUser()->getSfGuardUserProfile()->getIdempresa();
return Doctrine_Core::getTable('SdrivingMaquina')->createQuery('a')->where('a.idempresa = ?', $id_empresa)->execute();
}
SdrivingOperadorTable.class.php
public function fillChoice() {
$id_empresa = sfContext::getInstance()->getUser()->getGuardUser()->getSfGuardUserProfile()->getIdempresa();
return Doctrine_Core::getTable('SdrivingOperador')->createQuery('a')->where('a.idempresa = ?', $id_empresa)->execute();
}
SdrivingTurno.class.php
public function fillChoice() {
$id_empresa = sfContext::getInstance()->getUser()->getGuardUser()->getSfGuardUserProfile()->getIdempresa();
return Doctrine_Core::getTable('SdrivingTurno')->createQuery('a')->where('a.idempresa = ?', $id_empresa)->execute();
}
방법은 항상 동일합니다 :이 세 가지 코드입니다 . 내가 생성 된 쿼리를 확인하고 모두 괜찮아요 그리고 만약 내가 하나 이상의 값을 idoperador
및 idturno
에서 가져온 것입니다 예를 들어 phpMyAdmin에 각각을 실행하면 최신 렌더링됩니다. 이것은 매우 드문 행동이며 오류 또는 실수를 찾을 수 없으므로 여기에 도움이나 조언이 필요합니다. 내가 (위젯이 생성되는 곳이다) SdrivingRegistrosEmisoresForm.class.php
이 시도 ADITION으로
$id_empresa = $this->current_user->getSfGuardUserProfile()->getIdempresa();
$choices_operador = Doctrine_Core::getTable('SdrivingOperador')->createQuery('a')->where('a.idempresa = ?', $id_empresa)->execute();
$this->widgetSchema['idoperador'] = new sfWidgetFormSelect(array('choices' => $choices_operador));
그리고이 방법은 잘 작동하지만 가져온 각 항목에 대한 id
바로 의미되지 않습니다 :
id item real_id
0 Item1 2
1 Item2 16
2 Item4 3
나는 이것에 대해이 topic에서 이야기했으나 어떤 도움도 얻지 못했습니까?
옵션 * table_method이 * 당신의 방법과 같은 컬렉션을 반환하는 경우, sfWidgetFormDoctrineChoice에 명시된 바와 같이