Thanks a lot!
I have one more doubt. How to validate this
<?=$this->Form-
>input('content',array('type'=>'textarea','label'=>'Quotes'));?> //
This is post model
<?=$this->Form->input('Tag');?> // This is Tag model. How do i write
validation rule for this?
var $validate = array(
'content' => array(
'rule' => 'notEmpty',
'required' => true
),
'Tag' => array(
) // Will this work? I have problem
);
On Jun 20, 3:57 pm, euromark <[email protected]> wrote:
> or use
>
> if ($this->Post->validates()) {
> $this->Post->create();
> $this->Post->save(null, false)
>
> }
>
> will only validate once as well and use the correct data array
> (previously validated)
>
> On 20 Jun., 12:44, Tilen Majerle <[email protected]> wrote:
>
>
>
>
>
>
>
> > ok, first, why you validate 2 times?...just do
>
> > if ($this->Post->save($this->data))
>
> > it will automaticall validate your data...
>
> > --
> > Lep pozdrav, Tilen Majerlehttp://majerle.eu
>
> > 2011/6/20 prabha <[email protected]>
>
> > > Post Model
>
> > > var $validate = array(
> > > 'content' => array(
> > > 'rule' => 'notEmpty',
> > > 'required' => true
> > > )
> > > );
>
> > > add.ctp under posts/
>
> > > <?=$this->Form-
> > > >create('Posts',array('id'=>'articleform','enctype'=>'multipart/form-
> > > data','class'=>'form'));?>
> > > <?=$this->Form-
> > > >input('content',array('type'=>'textarea','label'=>'Quotes'));?>
> > > <?php echo $this->Form->end('Add Quote'); ?>
>
> > > posts_controller.php
> > > function add()
> > > {
> > > $this->Post->set($this->data);
> > > if ($this->Post->validates()) { $this->Post->create(); $this->Post-
> > > >save($this->data) } else{ //session set and redirect.}
>
> > > Whether i enter value or not in content textarea, it always goes to
> > > the else part
>
> > > What do i do wrongly?
>
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > [email protected] For more options, visit this group
> > > athttp://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php