Cake\View\Helper\FormHelper::submit PHP Method

submit() public method

### Options - type - Set to 'reset' for reset inputs. Defaults to 'submit' - templateVars - Additional template variables for the input element and its container. - Other attributes will be assigned to the input element.
public submit ( string | null $caption = null, array $options = [] ) : string
$caption string | null The label appearing on the button OR if string contains :// or the extension .jpg, .jpe, .jpeg, .gif, .png use an image if the extension exists, AND the first character is /, image is relative to webroot, OR if the first character is not /, image is relative to webroot/img.
$options array Array of options. See above.
return string A HTML submit button
    public function submit($caption = null, array $options = [])
    {
        if (!is_string($caption) && empty($caption)) {
            $caption = __d('cake', 'Submit');
        }
        $options += ['type' => 'submit', 'secure' => false, 'templateVars' => []];
        if (isset($options['name'])) {
            $this->_secure($options['secure'], $this->_secureFieldName($options['name']));
        }
        unset($options['secure']);
        $isUrl = strpos($caption, '://') !== false;
        $isImage = preg_match('/\\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption);
        $type = $options['type'];
        unset($options['type']);
        if ($isUrl || $isImage) {
            $unlockFields = ['x', 'y'];
            if (isset($options['name'])) {
                $unlockFields = [$options['name'] . '_x', $options['name'] . '_y'];
            }
            foreach ($unlockFields as $ignore) {
                $this->unlockField($ignore);
            }
            $type = 'image';
        }
        if ($isUrl) {
            $options['src'] = $caption;
        } elseif ($isImage) {
            if ($caption[0] !== '/') {
                $url = $this->Url->webroot(Configure::read('App.imageBaseUrl') . $caption);
            } else {
                $url = $this->Url->webroot(trim($caption, '/'));
            }
            $url = $this->Url->assetTimestamp($url);
            $options['src'] = $url;
        } else {
            $options['value'] = $caption;
        }
        $input = $this->formatTemplate('inputSubmit', ['type' => $type, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars']]);
        return $this->formatTemplate('submitContainer', ['content' => $input, 'templateVars' => $options['templateVars']]);
    }

Usage Example

 /**
  *
  * Create & return a Twitter Like submit input.
  *
  * New options:
  * 	- bootstrap-type: Twitter bootstrap button type (primary, danger, info, etc.)
  * 	- bootstrap-size: Twitter bootstrap button size (mini, small, large)
  *
  * Unusable options: div
  *
  **/
 public function submit($caption = null, array $options = array())
 {
     return parent::submit($caption, $this->_createButtonOptions($options));
 }
All Usage Examples Of Cake\View\Helper\FormHelper::submit