You could use Cake's translation.

locale/eng/LC_MESSAGES/default.po:

msgid "password_control"
msgstr "Confirm Password"

<li><?php echo __($field) .' - '. $error; ?></li>

But I notice you're already using the __() function elsewhere. If
you've already got a multilingual app then this may not be the best
choice (depending on your other field names and whether they appear in
other text messages). If you don't plan to ever make it multilingual,
don't use __() to echo arbitrary text as it'll just slow things down
needlessly.

On Fri, Apr 13, 2012 at 5:06 PM, CyberGlitch <[email protected]> wrote:
> Sort of a unique situation but maybe not? I'm curious if it's possible
> to change the "field" name when being displayed in validationErrors.
> Something that could be set in the model would make the most sense but
> can't seem to find what I'm looking for.
>
> Background. Doing custom flash messages and for bad ones.
>
> $this->set('errors', $this->User->validationErrors);
> $this->Session->setFlash('The user could not be saved. Please, try
> again.','flash_bad');
>
> Then in flash_bad element have.
>
>                                        <?php
>                                        echo $message;
>                                        if (!empty($errors)) { ?>
>                                                <div class="errors">
>                                                        <h3><?php __('There 
> are ');?><?php echo count($errors); ?> <?
> php __('error(s) in your submission:'); ?></h3>
>                                                        <ul>
>                                                                <?php foreach 
> ($errors as $field => $error) { ?>
>                                                                <li><?php echo 
> ucfirst($field) .' - '. $error; ?></li>
>                                                                <?php } ?>
>                                                        </ul>
>                                                </div>
>                                        <?php } ?>
>
> Some of the table field names aren't self explanatory. Easy example in
> doing a password repeat verification.
>
> 2 fields
> password
> password_control
>
> Error message generates
> Password - At least 6 characters
> Password_control - Does not match
>
> So is there a way, again thinking in the model, to set a different
> field name to be shown for the error messages and possibly other
> things.
>
>                'password_control' => array(
>                        'notempty' => array(
>                                'rule' => array('notEmpty'),
>                                'allowEmpty' => false,
>                                'message' => 'Does not match',
> ????----->                      'displayField' => 'Confirm Password'
>                        )
>
> to then get
> Password - At least 6 characters
> Confirm Password - Does not match
>
> --
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to