cakephp invalidate element array -


i using cakephp. have form element array. ex:-

<textarea name="data[user][0][description]> <textarea name="data[user][1][description]> 

from controller, need invalidate (manually) array field if empty , need show errors respective field. correct syntax invalidating field if element array ? know, following work single element . how element array ?

$this->user->invalidate("description"); 

unfortunately cannot invalidate field function.

but invalidate() does?

function invalidate($field, $value = true) {         if (!is_array($this->validationerrors)) {             $this->validationerrors = array();         }         $this->validationerrors[$field] = $value;     } 

it set validationerrors of model.

so, can following in controller (but appeal move validation in model):

$this->user->validationerrors[1]['description'] = 'your error message'; 

the following code invalidate second description in list.

hth


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -