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']]);
}