Skip to content

[Form] Support format without "y", "M" or "d" in DateField #7147

@webmozart

Description

@webmozart

DateField should support formats that don't contain the letters "y", "M" or "d" in order to select partial dates (e.g. months). The default values of the fields, when left away, should be the corresponding parts of the UNIX base timestamp 1970-01-01.

Example:

$builder->add('expires_at', 'date', array(
    'format' => 'MMyyyy',
));

A date submitted here will always have day "1", e.g. "2013-02-01".

Further related work:

TimeType currently supports the "with__" options for achieving this functionality (including or excluding single parts of the time). We should think about deprecating the "with__" options and supporting a "format" option instead, if this improves consistency.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions