imageButton() public static method

Generates an image submit button.
public static imageButton ( string $src, array $htmlOptions = [] ) : string
$src string the image URL
$htmlOptions array additional HTML attributes.
return string the generated button.
 /**
  * This function renders a built in button type.
  * The implementation is essentially a direct copy from
  * CFormButtonElement::render, the only difference is it uses TbHtml.
  * @return string the rendering result.
  */
 public function renderCore()
 {
     $attributes = $this->attributes;
     $method = self::$coreTypes[$this->type];
     if ($method === 'linkButton') {
         if (!isset($attributes['params'][$this->name])) {
             $attributes['params'][$this->name] = 1;
         }
     } elseif ($method === 'htmlButton') {
         $attributes['type'] = $this->type === 'htmlSubmit' ? 'submit' : ($this->type === 'htmlReset' ? 'reset' : 'button');
         $attributes['name'] = $this->name;
     } else {
         $attributes['name'] = $this->name;
     }
     if ($method === 'imageButton') {
         return TbHtml::imageButton(isset($attributes['src']) ? $attributes['src'] : '', $attributes);
     } else {
         return TbHtml::$method($this->label, $attributes);
     }
 }
Example #2
0
 public function testImageButton()
 {
     $I = $this->codeGuy;
     $html = TbHtml::imageButton('image.png', array('class' => 'button', 'name' => 'button'));
     $button = $I->createNode($html, 'input[type=image].btn');
     $I->seeNodeCssClass($button, 'button');
     $I->seeNodeAttributes($button, array('name' => 'button', 'src' => 'image.png'));
 }