Sorry to say but it is still not working.
Url:
http://localhost/cakephp/incomings/request/msisdn:/operator:AIRTEL/circle:DELHI
Incoming controller:
<?php
class IncomingsController extends AppController {
var $name = 'Incomings';
function request() {
$this->Incoming->set($this->params['named']);
if ($this->Incoming->validates()) {
$this->Session->setFlash("Correct");
} else {
$this->Session->setFlash("Incorrect");
}
}
}
?>
Incoming Model:
<?php
class Incoming extends AppModel {
var $name = 'Incoming';
var $validate = array(
'msisdn' => array(
'required' => true,
'allowEmpty' => false,
'rule' => 'numeric',
'message' => 'Please enter a valid msisdn',
));
}
?>
Please suggest.
Is validation only work for post request of is it also work for get request
like above?
Regards
Tapan Thapa
India
On Thu, Feb 17, 2011 at 4:49 PM, Dr. Tarique Sani <[email protected]>wrote:
> Try $this->Incoming->set($this->params['named']);
>
> Tarique
>
> On Thu, Feb 17, 2011 at 4:39 PM, Tapan Kumar Thapa
> <[email protected]> wrote:
> > I am dam got stuck here.
> >
> > Can some one suggest anything?
> >
> > BR
> > Tapan Thapa
> >
> > On Thu, Feb 17, 2011 at 10:02 AM, Tapan Kumar Thapa
> > <[email protected]> wrote:
> >>
> >> Hello,
> >>
> >> Now i am trying like this.
> >>
> >>
> >>
> http://localhost/cakephp/incomings/request/msisdn:/operator:AIRTEL/circle:DELHI
> >>
> >> but still validation from model class it not working. Please please
> >> suggest.
> >>
> >> My Model:
> >>
> >> <?php
> >>
> >> class Incoming extends AppModel {
> >>
> >> var $name = 'Incoming';
> >> var $validate = array(
> >> 'msisdn' => array(
> >> 'required' => true,
> >> 'allowEmpty' => false,
> >> 'rule' => 'numeric',
> >> 'message' => 'Please enter a valid msisdn',
> >> ));
> >>
> >> }
> >>
> >> ?>
> >>
> >> My Controller:
> >>
> >> <?php
> >>
> >> class IncomingsController extends AppController {
> >>
> >> var $name = 'Incomings';
> >>
> >> function request() {
> >> $this->Incoming->set($this->params['named']['msisdn']);
> >> if ($this->Incoming->validates()) {
> >> $this->Session->setFlash("Correct");
> >> } else {
> >> $this->Session->setFlash("Incorrect");
> >> }
> >> }
> >>
> >> }
> >>
> >> ?>
> >>
> >> I am always going in Correct message if condition however i have not
> given
> >> any value in msisdn parameter.
> >>
> >> Please please suggest something. I am clue less. Is validation only
> works
> >> in case of post request from view?
> >>
> >> Regards
> >> Tapan Thapa
> >> India
> >>
> >>
> >> On Thu, Feb 17, 2011 at 8:56 AM, Tapan Kumar Thapa
> >> <[email protected]> wrote:
> >>>
> >>> I don't mind using URL like this but are you sure that validation will
> >>> work like this?
> >>>
> >>> Regards
> >>> Tapan Thapa
> >>>
> >>> Sent from my iPhone
> >>>
> >>> On Feb 16, 2011, at 11:36 PM, euromark <[email protected]>
> >>> wrote:
> >>>
> >>> > you are mixing cake pretty urls and plain url style
> >>> >
> >>> > why not going with
> >>> > /.../x:1/y:2/z:3
> >>> > and using
> >>> > $this->params[named]
> >>> > ?
> >>> >
> >>> > if you don't mind my asking
> >>> >
> >>> >
> >>> > On 16 Feb., 12:49, Tapan Thapa <[email protected]> wrote:
> >>> >> Hello Community,
> >>> >>
> >>> >> I want to create a url like this.
> >>> >>
> >>> >>
> >>> >>
> http://localhost/cakephp/incomings/request/?msisdn=919871701375&opera...
> >>> >>
> >>> >> and i am accepting this request in my controller like below code and
> >>> >> passing it to model for validation but it is not working in case i
> >>> >> left any variable above blank like (circle=) or (msisdn=)
> >>> >>
> >>> >> incomings_controller.php
> >>> >>
> >>> >> <?php
> >>> >> class IncomingsController extends AppController {
> >>> >> var $name = 'Incomings';
> >>> >> function request() {
> >>> >> $this->Incoming->set($this->params['url']);
> >>> >> $this->Incoming->validates();}
> >>> >> }
> >>> >>
> >>> >> ?>
> >>> >>
> >>> >> incoming model:
> >>> >>
> >>> >> <?php
> >>> >> class Incoming extends AppModel {
> >>> >> var $name = 'Incoming';
> >>> >> var $validate = array(
> >>> >> 'msisdn' => array(
> >>> >> 'rule' => 'notEmpty',
> >>> >> 'required' => true,
> >>> >> 'message' => 'Please enter a valid msisdn',
> >>> >> 'last' => true
> >>> >> ),
> >>> >> 'operator' => array(
> >>> >> 'rule' => 'notEmpty',
> >>> >> 'required' => true,
> >>> >> 'message' => 'Please enter a valid operator',
> >>> >> 'last' => true
> >>> >> ),
> >>> >> 'circle' => array(
> >>> >> 'rule' => 'notEmpty',
> >>> >> 'required' => true,
> >>> >> 'message' => 'Please enter a valid circle',
> >>> >> 'last' => true
> >>> >> )
> >>> >> );
> >>> >>
> >>> >> }
> >>> >>
> >>> >> ?>
> >>> >>
> >>> >> Please suggest.
> >>> >>
> >>> >> Regards
> >>> >> Tapan Thapa
> >>> >> India
> >>> >> [email protected]
> >>> >
> >>> > --
> >>> > 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
> >>
> >
> > --
> > 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
> >
>
>
>
> --
> =============================================================
> PHP for E-Biz: http://sanisoft.com
> =============================================================
>
> --
> 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
>
--
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