У меня есть модель проекта, которая связана с моделью вопроса и моделью ответа.В project / view / я добавил форму для вставки нового вопроса, и она отлично работает.Но если я отправляю форму с ошибкой, она проверяется внутри / question / add.Я хочу, чтобы эти ошибки валидации отображались в проекте / представлении / странице.Как я могу это сделать?
Спасибо!
КОД:
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));
}
}
}
ФОРМА:
<?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));?>
Они оба похожи, так какони были испечены пирогом.