On Friday, 14 September 2012 15:42:36 UTC+8, resting wrote:
I have something like this in my view:
echo $this->Form->input('Modelname.1.fieldname'); (ref: http://book.cakephp.org/2.0/
en/core-libraries/helpers/ )form.html#field-naming- conventions I have this in my model:
public $validate = array( 'filename' => array('ruleFilenameEmpty' => array('rule' => 'notEmpty', 'required' => true, 'allowEmpty' => false, 'last' => true)));This is the structure of $this->request->data:
array( 'Capture' => array( (int) 0 => array( 'filename' => '', ) ) )But it always return a validation error, whether there's text in the textfield or not:
array( 'filename' => array( (int) 0 => 'ruleFilenameEmpty' ) )(printed from
debug($this->Capture->)validationErrors) Tested the validation with:
$this->Capture->set($this->request->data); if ($this->Capture->saveAll($ this->request->data)) { $this->Session->setFlash('< span style="color: red">' . __('It validates') . '</span>'); } I had tried all possible names for the validation. None works.
What am I doing wrong here?
Also I would like to validate each set of fields in $this->request->data before saving.
This is because there are some others to be done after it validates.
If the action fails, it should not save.
This cannot be done with saveAll().How can I evaluate each set of arrays in $this->request->data before saving?
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
No comments:
Post a Comment