this is the code:
/***********MODEL*******************************/
class Note extends AppModel
{
var $name = 'Note';
var $validate = array(
'title' => VALID_NOT_EMPTY,
'body' => VALID_NOT_EMPTY,
);
}
/****VIEW***********************************/
<h1>Add Note</h1>
<form action="<?php echo $html->url("/notes/add"); ?>" method="post">
<p>
Title:
<?php echo $html->input('Note/title', array('size' => '40'))?>
<?php echo $html->tagErrorMsg('Note/title', 'Title is required.')?
>
</p>
<p>
Body:
<?php echo $html->textarea('Note/body') ?>
<?php echo $html->tagErrorMsg('Note/body', 'Title is required.')?>
</p>
<p>
<?php echo $form->submit('Save') ?>
</p>
</form>
/**********Controller*****************************************/
class NotesController extends AppController
{
var $name = 'Notes';
var $uses = array('Note');
var $helpers = array('Html','Ajax','Form');
function index()
{
//$this->set('notes', $this->Note->findAll());
}
function view($id)
{
$this->Note->id = $id;
$this->set('data', $this->Note->read());
}
function add ()
{
if (empty($this->data))
{
$this->render();
}
else
{
if($this->Note->save($this->data))
{
$this->flash('Your note has been updated.','/notes/');
}
else
{
//Danger, Will Robinson. Validation errors.
$this->set('errorMessage', 'Please correct errors
below.');
$this->render();
}
}
}
On 29 mar, 13:29, "savagekabbage" <[EMAIL PROTECTED]> wrote:
> Do you have your model set up correctly to handle data validation?
>
> On Mar 29, 12:49 pm, "christianandradet" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > hi i am trying to do the validation that this page
> > teaches:http://manual.cakephp.org/chapter/validation
> > it works but the messages do not appear:
> > <?php echo $html->tagErrorMsg('Post/title', 'Title is required.')?>
> > I do not know whatis the problem, maybe it's something that needs to
> > be configured,
> > Please help
> > Thanks!- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---