Unfortunately, I don't think there is an easy solution for that.

However, If you have some sort of custom validation to assert the error,
for example in the controller,
if( empty($this->data['Person']['Address']['address1']) )
$this->Person->validationErrors['Address']['address1'] = 1;
then you can make custom error helper to check such error.

For example, make /app/views/helpers/error.php as follows
--------------------------------------------------------------------------------------------
<?php

class ErrorHelper extends Helper
{
    function tagErrorMsg($field, $text) {
        $error = 1;
                
        $pieces = explode("/", $field);
        $keys = "['".implode("']['", $pieces)."']";
        
        $variable = "\$this->validationErrors{$keys}";
        $validationError = eval("return {$variable};");

        if ($error == $validationError) {
            return sprintf('<div class="error_message">%s</div>', is_array($text) ? (empty($text[$error - 1]) ? 'Error in field' : $text[$error - 1]) : $text);
        } else {
            return null;
        }
    }   
}

?>
--------------------------------------------------------------------------------------------

Then your controller should include error helper by
var $helpers = array('Html', 'Error');

Then in your view (note: use $error instead of $html)
<?php echo $html->input('Person/Address/address1',
array('id' => 'person_address_address1', 'size' => '40',
'value' => $addresses['Address']['address1'], )) ?>
<?php echo $error->tagErrorMsg('Person/Address/address1', 'address is empty.'); ?>

The tagErrorMsg is from HTML helper, and I modified the error checking part.
It construct variable name to access multidimentional validationErrors array,
and get the value. It works for regular 'Model/field' case, too.
I am not sure if it is good code, but it works.

Example for custom validation and error helper is at
http://wiki.cakephp.org/tutorials:advanced_validation
and you might want to check the advanced custom validation for your need, too.

Hope this helps.

Sohei

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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