For the solution to do the clearing in the controller!
Change the buttons to:
echo $form->submit('Clear', array('name'=>'clear'));
echo $form->submit('Save Post', array('name'=>'save'));
In the controller, check for which button was used:
if (!empty($this->data))
{
...
if ( isset($this->params['form']) and isset($this->params['form']
['clear']) )
{
$this->data['Post']['title'] = '';
$this->data['Post']['body'] = '';
}
else
{
if ($this->Post->save($this->data))
{
...
Enjoy,
John
On Jul 17, 8:31 am, Dhileepen Chakravarthy
<[email protected]> wrote:
> Thanks all
>
> <!-- File: /app/views/posts/add.ctp -->
>
> <h1>Add Post</h1>
> <?php
> echo $form->create('Post');
> echo $form->input('title');
> echo $form->input('body', array('rows' => '3'));
> echo $form->button('Reset', array('type'=>'reset'), action=);
> echo $form->submit('Save Post');
> echo $form->end();
> ?>
>
> //controller
> function add()
> {
> if (!empty($this->data))
> {
> if ($this->Post->save($this->data))
> {
> $this->Session->setFlash('Your post has been saved.');
> $this->redirect(array('action' => 'index'));
> }
> }
> }
>
> how do i add the controller code here
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---