As Euromark suggested, you should be using $form->input(). You can
really customize how you want $form->input to return output now. You
can turn labels off with $form->input('Model.field', array('label' =>
false));
If you insist on using those form helper elements you'll need to use
$form->error('Model.field') to output the error message. Here is the
API for $form->error():
http://api.cakephp.org/class/form-helper#method-FormHelpererror
Hope that helps,
Nick
On Mar 11, 5:37 am, SeeVik <[email protected]> wrote:
> If I use $form->input() then I will also have to use the label for the
> input field it will display, which I don't want to, since I want my
> label in some specific CSS style.
>
> Can't the error message be displayed using $form->text() and other
> such helpers? In cakephp 1.1 it was $html->tagErrorMsg but I know that
> in cakephp 1.2 it has been deprecated. So what's the new way of doing
> it?
>
> Thanks and Regards
> ShiVik
>
> On Mar 11, 8:32 pm, euromark <[email protected]> wrote:
>
>
>
> > always use $form->input()
> > this will make a lot for u automatically
>
> > On 11 Mrz., 11:19, SeeVik <[email protected]> wrote:
>
> > > Hello all
>
> > > I am using cakephp 1.2 and I am having problem in displaying the error
> > > messages for the data validation of a form. I created the form like
> > > this....
>
> > > <?php echo $form->create( 'Posts', array( 'action' => 'index' ) ); ?>
> > > <?php echo $form->text( 'text' ); ?>
> > > <?php echo $form->text( 'value' ); ?>
> > > <?php echo $form->end( 'Submit' ); ?>
>
> > > In my model Post.php
>
> > > I have defined $validate like this....
>
> > > $validate = array(
> > > 'text' => array( 'rule' => 'notEmpty', 'message' => 'This is
> > > needed' ),
> > > 'value' => array( 'rule' => 'notEmpty', 'message' => 'This is
> > > needed' )
> > > );
>
> > > In my PostsController.php I did the validation like this...
>
> > > function index() {
> > > if( $this->data ) {
> > > $this->Post->set( $this->data );
> > > if( $this->Post->validates() ) {
> > > // some action here
> > > }
> > > else {
> > > // other action here
> > > }
> > > $this->set( 'check', $this->Post->validationErrors );
>
> > > So when I see the variable "check" in my view, I can see the messages
> > > I defined in my model. But I cannot see the error message below my
> > > text fields in the view. Why is that? What am I doing wrong over here?
>
> > > Thanks and Regards
> > > ShiVik
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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