Modifying dateTimeOptionTag() in CakePHP
CakePHP has all sorts of nifty form helpers that I would ordinarily never use, except for the fact that they get put in the auto-generated views. The helper that creates a day/month/year select tag automatically lists years from like 1947-2017... way too many. I normally don't care, but a client complained about it this morning, so I had to go searching around for a way to fix it. Rather than go into the code itself, I prefer to be lazy and just search the net to see if anyone else has written something about it. Jackpot! Some dude has written how to modify the dateTimeOptionTag().
In case that page goes blank, the gist is editing
/cake/libs/view/helpers/html.php
, which is the HTML Helper. Find the calls to yearOptionTag(), and change the third and fourth parameters to your start and end year, respectively. I used date("Y")
and date("Y", strtotime("+4 years"))
.
[Edit] Alternately, just modify yearOptionTag() itself... the place to change the code is pretty obvious.
Comments