Entity setError on compound fieldName


#1

I have this $this->Form->control() items:

“number_of_frames_by_size.A1”,
“number_of_frames_by_size.A2”
“number_of_frames_by_size.A3”
“number_of_frames_by_size.A4”

when I submit form, it is show as array on entity, but I need to set a error to one of this fields.

I tried:

$this->setError(‘number_of_frames_by_size.A1’, ‘message’);
$this->setError(‘number_of_frames_by_size_A1’, ‘message’);
$this->setError(‘number_of_frames_by_size[A1]’, ‘message’);

none worked


#2

In an entity setError() should be the method to use. Have you made sure that your form is using the entity as its ‘data source’? You would do this with $this->Form->create($entity). If you don’t do that the FormHelper doesn’t know about the entity and can’t read validation errors from it.