デフォルトで lang:’ja’ を使っているため、日付フォーマットが yyyy/mm/dd になるように小細工をしています。
また、オプションは lang, startYear, endYear のみ有効になっています。
function dateInput($fieldName, $htmlAttributes = array(), $calOptions = array(), $return = false, $typeModel = true) {
if (!isset($htmlAttributes['value'])) {
$date = $this->tagValue($fieldName);
if ($date) {
$htmlAttributes['value'] = date('Y/m/d', strtotime($date));
}
}
$result = $this->input($fieldName, $htmlAttributes, $return);
if(!empty($htmlAttributes['id'])){
$styleId = $htmlAttributes['id'];
}else if($typeModel == true){
$this->setFormTag($fieldName);
$styleId = $this->model . Inflector::camelize($this->field);
}else{
$this->field = $fieldName;
$styleId = $this->field;
}
$script = " InputCalendar.createOnLoaded('{$styleId}', {";
$lang = !empty($calOptions['lang']) ? "lang:{$calOptions['lang']} " : "lang:'ja'";
$script .= $lang;
if (!empty($calOptions['startYear'])) {
$script .= ", startYear:{$calOptions['startYear']} ";
}
if (!empty($calOptions['endYear'])) {
$script .= ", endYear:{$calOptions['endYear']} ";
}
$script .= "});";
if (AUTO_OUTPUT && $return == false) {
echo $result;
echo $this->Javascript->codeBlock($script, false);
} else {
return ($result . $this->Javascript->codeBlock($script, false));
}
}

スプーキーズラボブログは株式会社スプーキーズの技術関連の情報を発信するブログです。プロダクト一覧、お問い合わせなどはスプーキーズラボのサイトをご覧ください。
バグ報告はコメントか、お問い合わせからお願いします。
設置サポートは有料でのみ受け付けています。その場合も、お問い合わせからお願いします。