activeRadioButton() 공개 정적인 메소드

Generates a radio button for a model attribute.
public static activeRadioButton ( CModel $model, string $attribute, array $htmlOptions = [] ) : string
$model CModel the data model.
$attribute string the attribute.
$htmlOptions array additional HTML attributes.
리턴 string the generated radio button.
예제 #1
0
 public function testActiveRadioButton()
 {
     $I = $this->codeGuy;
     $html = TbHtml::activeRadioButton(new Dummy(), 'radio', array('class' => 'input', 'label' => 'Label text'));
     $body = $I->createNode($html, 'body');
     $hidden = $body->filter('input[type=hidden]');
     $I->seeNodeAttributes($hidden, array('id' => 'ytDummy_radio', 'name' => 'Dummy[radio]', 'value' => '0'));
     $label = $body->filter('label');
     $I->seeNodeCssClass($label, 'radio');
     $radio = $label->filter('input[type=radio]');
     $I->seeNodeAttributes($radio, array('class' => 'input', 'checked' => 'checked', 'id' => 'Dummy_radio', 'name' => 'Dummy[radio]', 'value' => '1'));
     $I->seeNodePattern($label, '/> Label text$/');
 }
예제 #2
0
 /**
  * Renders a radio button for a model attribute.
  * This method is a wrapper of {@link TbHtml::activeRadioButton}.
  * Please check {@link TbHtml::activeRadioButton} for detailed information
  * about the parameters for this method.
  * @param CModel $model the data model
  * @param string $attribute the attribute
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated radio button
  */
 public function radioButton($model, $attribute, $htmlOptions = array())
 {
     return $this->wrapControl(TbHtml::activeRadioButton($model, $attribute, $htmlOptions));
 }
예제 #3
0
 /**
  * Renders a radio button for a model attribute.
  * @param CModel $model the data model.
  * @param string $attribute the attribute.
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated radio button.
  * @see TbHtml::activeRadioButton
  */
 public function radioButton($model, $attribute, $htmlOptions = array())
 {
     return TbHtml::activeRadioButton($model, $attribute, $htmlOptions);
 }
예제 #4
0
 public function testUncheckValueOptionForCheckboxesAndRadioInputs()
 {
     $I = $this->codeGuy;
     $items = array(0);
     $model = new Dummy();
     $outputsWithHidden = array('checkbox' => TbHtml::checkBox('cb1', false, array('uncheckValue' => 1)), 'checkboxList' => TbHtml::checkBoxList('cb2', 0, $items, array('uncheckValue' => 1)), 'radio' => TbHtml::radioButton('rd1', false, array('uncheckValue' => 1)), 'radioList' => TbHtml::radioButtonList('rd2', 0, $items, array('uncheckValue' => 1)), 'activeCheckbox' => TbHtml::activeCheckBox($model, 'checkboxList'), 'activeCheckboxList' => TbHtml::activeCheckBoxList($model, 'checkboxList', $items), 'activeRadio' => TbHtml::activeRadioButton($model, 'radioList'), 'activeRadioList' => TbHtml::activeRadioButtonList($model, 'radioList', $items));
     foreach ($outputsWithHidden as $output) {
         $I->seeNodeChildren($I->createNode($output), array('input[type=hidden]'));
     }
     // comparing against null 'uncheckValue' option
     $noHiddenOptions = array('uncheckValue' => null);
     $outputsWithoutHidden = array('checkbox' => TbHtml::checkBox('cb1'), 'checkboxList' => TbHtml::checkBoxList('cb2', 0, $items), 'radio' => TbHtml::radioButton('rd1'), 'radioList' => TbHtml::radioButtonList('rd2', 0, $items), 'activeCheckbox' => TbHtml::activeCheckBox($model, 'checkboxList', $noHiddenOptions), 'activeCheckboxList' => TbHtml::activeCheckBoxList($model, 'checkboxList', $items, $noHiddenOptions), 'activeRadio' => TbHtml::activeRadioButton($model, 'radioList', $noHiddenOptions), 'activeRadioList' => TbHtml::activeRadioButtonList($model, 'radioList', $items, $noHiddenOptions));
     foreach ($outputsWithoutHidden as $output) {
         $I->dontSeeNodeChildren($I->createNode($output), array('input[type=hidden]'));
     }
 }