Welcome to the Cookbook

loading...
Please login to continue

7.3.5.4 month

month(string $fieldName, mixed $selected, array $attributes, boolean $showEmpty)

Creates a select element populated with month names.

<?php
echo $form->month('mob');
?>
  1. <?php
  2. echo $form->month('mob');
  3. ?>

Will output:

<select name="data[User][mob][month]" id="UserMobMonth">
<option value=""></option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>

You can pass in your own array of months to be used by setting the 'monthNames' attribute (CakePHP 1.3 only), or have months displayed as numbers by passing false. (Note: the default months are internationalized and can be translated using localization.)

<?php
echo $form->month('mob', null, array('monthNames' => false));
?>
  1. <?php
  2. echo $form->month('mob', null, array('monthNames' => false));
  3. ?>