I have a project model which is related to a question model and a answer model. In project/view/ I added a form to insert a new question, and it works fine. But if I send the form with an error, it validates inside /question/add. I want those validation errors to show at the project/view/ page. How can I do that?
Thanks!
CODE:
function add() {
if (!empty($this->data)) {
$this->Question->create();
if ($this->Question->save($this->data)) {
$this->Session->setFlash(__('The question has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The question could not be saved. Please, try again.', true));
}
}
}
THE FORM:
<?php echo $this->Form->create('Question', array('action' => 'add'));?>
<fieldset>
<legend><?php __('Add Question'); ?></legend>
<?php
echo $this->Form->input('text');
echo $this->Form->hidden('Project', array('value' => $project['Project']['id']));
?>
</fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
Both of them are similar, since they were baked by Cake.