나는 잘못된 방향으로 가고 있다고 확신하지만 sfWidgetFormChoice에서 내 선택 사항 중 하나에서 배열 키를 해제해야합니다. 해당 변수를 Form으로 가져 오는 유일한 방법은 작업에서 가져 오는 것입니다. 여기에 내가 가진 무엇 :액션에서 폼으로 변수를 전달하는 방법
이작업 :
이$id = $request->getParameter('id');
$deleteForm = new UserDeleteForm();
$choices = array();
$choices = $deleteForm->getWidgetSchema('user')->getAttribute('choices');
unset($choices[$id]); //I obviously don't want the user to be able to transfer to the user being deleted
$this->deleteForm = $deleteForm;
형태 :
$users = Doctrine_Core::getTable('sfGuardUser')->getAllCorpUsers()->execute();
$names = array();
foreach($users as $userValue){
$names[$userValue->getId()] = $userValue->getProfile()->getFullName();
};
// unset($names[$id]); //this works, but I can't figure out how to get $id here.
$this->widgetSchema['user'] = new sfWidgetFormChoice(array(
'choices' => $names
));
$this->validatorSchema['user'] = new sfValidatorChoice(array(
'required' => true,
'choices' => $names
));
왜 symfony2에 태그를 지정 했습니까? – cheesemacfly
symfony2 사용자가 1.4로 시작한 이유가 있습니다. 나는 가능한 한 내 질문에 많은 노출을 찾고있다. – Patrick
대신 [a bounty] (http://stackoverflow.com/help/bounty)를 사용해야합니다. 관련성없는 태그를 질문에 추가하면 가시성을 얻을 수 없습니다. – cheesemacfly