birthday Field Type

A date field that specializes in handling birthdate data.

Can be rendered as a single text box, three text boxes (month, day, and year), or three select boxes.

This type is essentially the same as the date type, but with a more appropriate default for the years option. The years option defaults to 120 years ago to the current year.

Underlying Data Type can be DateTime, string, timestamp, or array (see the input option)
Rendered as can be three select boxes or 1 or 3 text boxes, based on the widget option
Options
Inherited options
Parent type date
Class Symfony\Component\Form\Extension\Core\Type\BirthdayType

Field Options

years

type: array default: 120 years ago to the current year

List of years available to the year field type. This option is only relevant when the widget option is set to choice.

Inherited options

These options inherit from the date type:

widget

type: string default: choice

The basic way in which this field should be rendered. Can be one of the following:

  • choice: renders three select inputs. The order of the selects is defined in the pattern option.
  • text: renders a three field input of type text (month, day, year).
  • single_text: renders a single input of type text. User’s input is validated based on the format option.

input

type: string default: datetime

The format of the input data - i.e. the format that the date is stored on your underlying object. Valid values are:

  • string (e.g. 2011-06-05)
  • datetime (a DateTime object)
  • array (e.g. array('year' => 2011, 'month' => 06, 'day' => 05))
  • timestamp (e.g. 1307232000)

The value that comes back from the form will also be normalized back into this format.

months

type: array default: 1 to 12

List of months available to the month field type. This option is only relevant when the widget option is set to choice.

days

type: array default: 1 to 31

List of days available to the day field type. This option is only relevant when the widget option is set to choice:

'days' => range(1,31)

format

type: integer or string default: IntlDateFormatter::MEDIUM

Option passed to the IntlDateFormatter class, used to transform user input into the proper format. This is critical when the widget option is set to single_text, and will define how to transform the input. By default, the format is determined based on the current user locale; you can override it by passing the format as a string.

pattern

type: string

This option is only relevant when the widget is set to choice. The default pattern is based off the format option, and tries to match the characters M, d, and y in the format pattern. If no match is found, the default is the string {{ year }}-{{ month }}-{{ day }}. Tokens for this option include:

  • {{ year }}: Replaced with the year widget
  • {{ month }}: Replaced with the month widget
  • {{ day }}: Replaced with the day widget

data_timezone

type: string default: system default timezone

Timezone that the input data is stored in. This must be one of the PHP supported timezones

user_timezone

type: string default: system default timezone

Timezone for how the data should be shown to the user (and therefore also the data that the user submits). This must be one of the PHP supported timezones

このページのコンテンツ

前のドキュメント

Form Type リファレンス

次のドキュメント

checkbox Field Type

ソース



クイックリンク

コメントリスト


ご質問や翻訳不備等お気軽にコメントください。


現在、翻訳が古くなっている箇所が多くあります。1箇所、1行などほんの少量でもかまいませんので、ドキュメント翻訳にご協力いただける方を募集しています。日本 Symfony ユーザー会メーリングリストまでご連絡ください。