示例#1
0
 /**
  * renderRadio
  *
  * @test
  */
 public function renderRadio()
 {
     $htmlGenerated = tx_t3devapi_html::renderRadio('test', 2, array(1, 2, 3), array('class' => 'test'));
     $html = '<input type="radio" value="2" name="test" id="test" checked="checked" class="test" />';
     $this->debug($htmlGenerated);
     $this->assertEquals(trim($htmlGenerated), $html);
 }
 /**
  * Generate a field from a tca type "radio"
  *
  * @param string       $field
  * @param string|array $val
  * @return string
  */
 public function getFieldFromTcaRadio($field, $val)
 {
     $config = $this->getFieldConfig($field);
     $attributes = array();
     $content = '';
     if (!empty($config['items'])) {
         foreach ($config['items'] as $itemKey => $item) {
             $contentRadio = '';
             if ($val == $itemKey) {
                 $attributes['checked'] = 'checked';
             }
             $id = $this->getPrefix($field) . '_' . $itemKey;
             $attributes['id'] = tx_t3devapi_html::cleanId($id);
             $contentRadio .= tx_t3devapi_html::renderRadio($this->getPrefix($field), $itemKey, array(), $attributes);
             $contentRadio .= tx_t3devapi_html::renderLabel($id, $GLOBALS['TSFE']->sL($item[0]));
             $content .= '<div id="' . $this->extKey . '_' . $this->pObj->cObj->data['uid'] . '_' . $field . '_radio_' . $itemKey . '" class="">' . $contentRadio . '</div>';
             unset($attributes['checked']);
         }
     }
     return $content;
 }