Its now working create() method should be like this:
$this->Form->create('ItQueryResponse', array('action' => 'add'));,
otherwise the form submits to the view() method of your controller.
On Thursday, 21 February 2013 09:07:51 UTC+2, Victor Musvibe wrote:
>
> Hi there
>
> I have an element that i am calling with a view file. The element is a add
> view that is add.ctp, challenge that im having now is that the element is
> not inserting form input into the table (it_query_responses).
>
> here is how i am calling my element within the view -
>
> <?php echo $this->Element('ItQueryResponses/add'); ?>
>
> and here is the code for the element
>
> <?php echo $this->Form->create('ItQueryResponse'); ?>
> <legend><?php echo __('Add It Query Response'); ?></legend>
> <?php
> echo $this->Form->input('it_query_id');
> echo $this->Form->input('hr_employee_id');
> echo $this->Form->input('response');
> echo $this->Form->input('it_query_status_id');
> ?>
> <?php echo $this->Form->end(__('Submit')); ?>
>
> and here is add function in ItQueryResponsesController
>
> public function add() {
> if ($this->request->is('post')) {
> $this->ItQueryResponse->create();
> if ($this->ItQueryResponse->save($this->request->data)) {
> $this->Session->setFlash(__('The it query response has been saved'));
> $this->redirect(array('action' => 'index'));
> } else {
> $this->Session->setFlash(__('The it query response could not be saved.
> Please, try again.'));
> }
> }
> $itQueries = $this->ItQueryResponse->ItQuery->find('list');
> $hrEmployees = $this->ItQueryResponse->HrEmployee->find('list');
> $itQueryStatuses = $this->ItQueryResponse->ItQueryStatus->find('list');
> $this->set(compact('itQueries', 'hrEmployees', 'itQueryStatuses'));
> }
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.