2014-05-20 10 views
1

Zend Framework 2, Doctrine Module 및 SQLServer를 사용하여 여러 제품을 구축하고 있습니다.Zend Framework 2 라디오 버튼 null 값 기본값

Zend \ Form \ Radio와 관련하여 질문이 있습니다.

는 I는 형태로 정의 된 다음 한 :

// boolean $disabled_access 
$this->add(array(
     'name' => 'disabled_access', 
     'type' => 'radio', 
     'options' => array(
      'label' => 'Disabled Access', 
      'value_options' => array('1'=>"Yes", '0' => 'No'), 
      'allow_empty' => true, 
      'nullable' => true, 
     ), 
     'attributes' => array('value' => null), 
)); 

는 그것은 $building entity에 바인딩됩니다.

DB의 'disabled_access'값을 true으로 설정하면 라디오 버튼이 올바르게 렌더링됩니다. 마찬가지로 그것은 false으로 설정됩니다.

그러나 열에 NULL 값이 있으면 라디오 단추의 기본값은 '아니요'입니다. 세 가지 결과를 모두 표시하도록 설정하려면 어떻게해야합니까?

+0

같은 문제가 있습니까? 수정 한 적이 있습니까? –

답변

0

이 충분해야한다 - 데이터베이스에 값이

$this->add(array( 'name' => 'disabled_access', 'type' => 'radio', 'options' => array( 'label' => 'Disabled Access', 'value_options' => array('1'=>'Yes', '0' => 'No'), ), ) );

경우 -
은 1 -> '예'라디오 버튼이 선택됩니다
는 에게 0 -> '없음'라디오 버튼이있을 것입니다 선택,
NULL -> 아무도 선택되지 않습니다.

나를 위해 일합니다.

도움이되기를 바랍니다.