EN | CS | Přihlásit | Registrovat

Obsah

AdvancedSubmit­Button

je plně stylovatelné odesílací tlačítko s podporou html obsahu.

Autor Honza Kuchař
Licence New BSD License
Diskuse http://forum.nette.org/…submitbutton?…
Demo není

Tento plugin nejspíš nebude fungovat ve všech prohlížeči! (viz http://forum.nette.org/…iewtopic.php?…)

Kód pluginu

BaseForm.php: (předek všech formulářů)

class BaseForm extends AppForm {
/**
* Adds button used to submit form.
* @param string control name
* @param string caption
* @return AdvancedSubmitButton
*/

public function addAdvSubmit($name, $caption, $icon = null)
{
return $this[$name] = new AdvancedSubmitButton($caption, $icon);
}
}

AdvancedSubmit­Button.php:

class AdvancedSubmitButton extends SubmitButton {

var $icon = null;

var $showCaption = true;

/**
* @param string caption
* @param string icon url
*/

public function __construct($caption = NULL,$icon=NULL)
{
parent::__construct($caption);
if($icon) {
$this->iconPrototype->src = $icon;
}
$this->control->setName("button")->type = 'submit';
//$this->control->class[] = "button";
$this->control->class[] = "submit";
}

public function getIconPrototype() {
if(!$this->icon) {
$this->icon = Html::el("img");
}
return $this->icon;
}

function hideCaption(){
$this->showCaption = false;
return $this;
}

public function getControl($caption = NULL){
$control = parent::getControl($caption);
$control->setText(""); // Delete content
if($this->icon) {
$control->class[] = "hasIcon";
$this->icon->alt = $this->caption;
$control->add($this->icon);
}
if($this->showCaption) {
$control->class[] = "hasCaption";
$control->add(Html::el("span class=caption")->setHtml($this->caption));
}

// CSS classes:
if($this->icon and !$this->showCaption) {
$control->class[] = "hasIconAndNoCaption";
}elseif(!$this->icon and $this->showCaption) {
$control->class[] = "hasCaptionAndNoIcon";
}elseif($this->icon and $this->showCaption){
$control->class[] = "hasCaptionAndIcon";
}

return $control;
}

}

Login to submit a comment