Cake\View\Helper\FormHelper::year PHP Метод

year() публичный Метод

### Attributes: - empty - If true, the empty select option is shown. If a string, that string is displayed as the empty element. - orderYear - Ordering of year values in select options. Possible values 'asc', 'desc'. Default 'desc' - value The selected value of the input. - maxYear The max year to appear in the select element. - minYear The min year to appear in the select element.
public year ( string $fieldName, array $options = [] ) : string
$fieldName string Prefix name for the SELECT element
$options array Options & attributes for the select elements.
Результат string Completed year select input
    public function year($fieldName, array $options = [])
    {
        $options = $this->_singleDatetime($options, 'year');
        $len = isset($options['val']) ? strlen($options['val']) : 0;
        if (isset($options['val']) && $len > 0 && $len < 5) {
            $options['val'] = ['year' => (int) $options['val'], 'month' => date('m'), 'day' => date('d')];
        }
        return $this->dateTime($fieldName, $options);
    }

Usage Example

 public function year($fieldName, array $options = [])
 {
     $options = $this->_injectStyles($options, 'form-control');
     return parent::year($fieldName, $options);
 }