On 5/5/06, tinmar <[EMAIL PROTECTED]> wrote:
I try to validate but i can't see error message
the Model :
class Post extends AppModel
{
var $name = 'Post';
var $validate = array(
'title' => VALID_NOT_EMPTY,
'body' => VALID_NOT_EMPTY
);
}
The controler and add method
<?php
class PostsController extends AppController
{
var $name = 'Posts';
function index()
{
$this->set('posts', $this->Post->findAll());
}
function view($id = null)
{
$this->Post->id = $id;
$this->set('post', $this->Post->read());
}
function add()
{
if (!empty($this->data))
{
if ($this->Post->save($this->data))
{
$this->flash('Your post has been saved.','/posts');
}
}
else
{
$this->validateErrors($this->Post);//set the values for the
tagErrorMsg
$this->render();
}
}
}
?>
And the view
<h1>Add Post</h1>
<form method="post" action="" echo $html->url('/posts/add')?>">
<p>
Title:<?php echo $html->input('Post/title', array('size' =>
'40'))?>a<?php echo $html->tagErrorMsg('Post/title', 'Title is
required.') ?>a
</p>
<p>
Body:<?php echo $html->textarea('Post/body', array('rows'=>'10'))
?>b<?php echo $html->tagErrorMsg('Post/body', 'Body is required.') ?>b
</p>
<p>
<?php echo $html->submit('Save') ?></p>
</form>
Thanks in advance
Tinmar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" 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
-~----------~----~----~----~------~----~------~--~---
- Re: Newbie problems BoBB
- Re: Newbie problems tinmar
- Re: Newbie problems Martin Roy
- Re: Newbie problems tinmar
