简体   繁体   中英

Sequence of rules

My application is not working correctly with my input parametres.

I have 2 rules at config urlManager:

'<controller:\w+>/<action:\w+>/<factor:\w+>/<id:\d+>'=>'<controller>/<action>',

'<controller:\w+>/<action:\w+>/<factor:\w+>/<ids:((id\d+)|\d)+>'=>'<controller>/<action>'

At my action I try 2 inputs: id12id78 and 87 (any number).

With the first input, the action gets id12id78 , but if I try the second input, my $ids parameter is empty.

How I can fix the bug?

Well, nothing strange :

  • id12id78 : the second rule will be applied : $ids => id12id78
  • 87 : the first rule will be applied : $id => 87

I don't think you need to different params here, you should use only id , eg :

'<controller:\w+>/<action:\w+>/<factor:\w+>/id<id:\d+>'=>'<controller>/<action>',   
'<controller:\w+>/<action:\w+>/<factor:\w+>/<id:\d+>'=>'<controller>/<action>',

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM