adding error to html tags array, adjust form helper to use it, closes #2088, closes #1022

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6196 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-12-22 06:37:30 +00:00
parent 81b074cf1f
commit ea1b6581bc
2 changed files with 8 additions and 9 deletions

View file

@ -372,13 +372,15 @@ class FormHelper extends AppHelper {
if ($text != null) { if ($text != null) {
$error = $text; $error = $text;
} elseif (is_numeric($error)) { } elseif (is_numeric($error)) {
$error = 'Error in field ' . Inflector::humanize($this->field()); $error = __('Error in field ' . Inflector::humanize($this->field()), true);
} }
if ($options['escape']) { if ($options['escape']) {
$error = h($error); $error = h($error);
unset($options['escape']);
} }
if ($options['wrap'] === true) { if ($options['wrap'] === true) {
return $this->Html->div($options['class'], $error); unset($options['wrap']);
return $this->output(sprintf($this->Html->tags['error'], $this->_parseAttributes($options), $error));
} else { } else {
return $error; return $error;
} }
@ -407,11 +409,7 @@ class FormHelper extends AppHelper {
if (substr($text, -3) == '_id') { if (substr($text, -3) == '_id') {
$text = substr($text, 0, strlen($text) - 3); $text = substr($text, 0, strlen($text) - 3);
} }
$text = Inflector::humanize(Inflector::underscore($text)); $text = __(Inflector::humanize(Inflector::underscore($text)), true);
if (!empty($text)) {
$text = __($text, true);
}
} }
if (isset($attributes['for'])) { if (isset($attributes['for'])) {
@ -759,7 +757,7 @@ class FormHelper extends AppHelper {
$legend = $attributes['legend']; $legend = $attributes['legend'];
unset($attributes['legend']); unset($attributes['legend']);
} elseif (count($options) > 1) { } elseif (count($options) > 1) {
$legend = Inflector::humanize($this->field()); $legend = __(Inflector::humanize($this->field()), true);
} }
$label = true; $label = true;

View file

@ -92,7 +92,8 @@ class HtmlHelper extends AppHelper {
'charset' => '<meta http-equiv="Content-Type" content="text/html; charset=%s" />', 'charset' => '<meta http-equiv="Content-Type" content="text/html; charset=%s" />',
'ul' => '<ul%s>%s</ul>', 'ul' => '<ul%s>%s</ul>',
'ol' => '<ol%s>%s</ol>', 'ol' => '<ol%s>%s</ol>',
'li' => '<li%s>%s</li>' 'li' => '<li%s>%s</li>',
'error' => '<div%s>%s</div>'
); );
/** /**
* Base URL * Base URL