Cake\View\Helper\FormHelper::button PHP Метод

button() публичный Метод

The type attribute defaults to type="submit" You can change it to a different value by using $options['type']. ### Options: - escape - HTML entity encode the $title of the button. Defaults to false.
public button ( string $title, array $options = [] ) : string
$title string The button's caption. Not automatically HTML encoded
$options array Array of options and HTML attributes.
Результат string A HTML button tag.
    public function button($title, array $options = [])
    {
        $options += ['type' => 'submit', 'escape' => false, 'secure' => false];
        $options['text'] = $title;
        return $this->widget('button', $options);
    }

Usage Example

Пример #1
0
 /**
  * Creates a button.
  *
  * This method creates a button. To create a POST button, you should use
  *  the `postButton()` method.
  * Instead, to create a link with the appearance of a button, you should
  *  use the `button()` method provided by `HtmlHelper`.
  * @param string $title The button label or an image
  * @param array $options HTML attributes and options
  * @return string
  * @see postButton(), MeTools\View\Helper\HtmlHelper::button()
  */
 public function button($title, array $options = [])
 {
     $options = $this->optionsDefaults(['type' => 'button'], $options);
     if ($options['type'] === 'submit') {
         $options = $this->addButtonClasses($options, 'success');
     } else {
         $options = $this->addButtonClasses($options);
     }
     list($title, $options) = $this->addIconToText($title, $options);
     return parent::button($title, $options);
 }
All Usage Examples Of Cake\View\Helper\FormHelper::button