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);
    }
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);
    }
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 ) ; }
Returns a SELECT element for years

### 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.

@param string $fieldName Prefix name for the SELECT element
@param array $options Options & attributes for the select elements.
@return string Completed year select input
@link https://book.cakephp.org/3.0/en/views/helpers/form.html#creating-year-inputs
Returns a SELECT element for years