cphalcon: Default value for an action parameter is ignored

Let’s suppose I have a controller like this:

class IndexController extends ListController {

  public function indexAction($hero = 'superman') {
    echo $hero;
  }

}

When I get the http://mysite.com, without any parameters, Phalcon passes to the action an empty string instead of NULL. This implies the default parameter value is ignored. To fix this behaviour you have to do this:

class IndexController extends ListController {

  public function indexAction($hero) {
    if (empty($hero))
      echo 'superman';
  }

}

Sometimes you want that http://mysite.com provide the same result of http://mysite.com/superman. Imagine for example a default order or results in a list.

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 19 (17 by maintainers)

Most upvoted comments

Phalcon 2 doesn’t have this bug anymore, just checked.

I will check and I’ll let you know.