Surely I can add a parameter like add($pid). and call like control/add/4.
But when any validation error , it collapses and tell
“missing argument 1 for ConsultingDetsController::add()”
From where cakePHP default add() is calling and how to solve this issue?
thanks…
Surely I can add a parameter like add($pid). and call like control/add/4. But when
Share
When you write a function, and want to pass a variable in the URL, you’d write it like this:
But – if written like that, ANY time you try to access this function, you MUST have that variable, or you’ll get the error you mentioned.
If you’d like to be able to access the function and SOMETIMES pass it a variable (like when you’re submitting a form, and don’t necessarily need the URL variable for example), just set the value of the parameter:
Doing this will allow you to call the function via
controller/add/4orcontroller/addand will not cause an error.Then, just make sure you verify $pid has data before trying to use it for something important: