0
votes

im currently trying to connect CakePHP with ExtJs4 but i face the following problem:

the Ext Validation Errors (displayed in the msgTarget fields of the form) seem to work perfectly if the name of the formfield is e.g. 'username' and the validation answer is 'username' 'notempty' or similar.

but as cakephp is using default fieldnames like data[User][username], i'm running into Problems so that i cannot display the (json encoded) validation messages in those fields (msgTarget)

Perhaps anyone of you has solved this issue

thanks in advance duderion

1

1 Answers

0
votes

Before sending the validation messages from CakePHP to ExtJS you could simply transform the names in the format ExtJS needs them.

That should look something like this:

$extErrors = array();
foreach($errors as $key => $value) {
    $fieldname = substr($key, strrpos($key, '[')+1); // remove the front part
    $fieldname = substr($key, 0, strlen($key); // remove the closing ]
    $extErrors[$fieldname] = $value;
}

Or you might want to check out Bancha.