Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Form] Document usage of empty_data #998

Closed
Labels
FormactionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)
Milestone
@webmozart

Description

@webmozart

The usage of theempty_data option for forms should be documented.empty_data allows to set the data set in the form when it is bound andsetData() wasn't called before.

By default, this isnull or, ifdata_class is set, a new instance of that given class (created by using a no-args constructor).

The option can be overridden by setting a static value (1) or by setting a closure (2), that receives aFormInterface instance as first argument. (2) should be preferred, as it only creates objects on demand.

(1)

public function getDefaultOptions(){    return array(        'empty_data' => new User($this->someDependency)    );}

(2)

public function getDefaultOptions(){    return array(        'empty_data' => function (FormInterface $form) {            return new User($form->get('username')->getData());        }    );}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FormactionableClear and specific issues ready for anyone to take them.good first issueIdeal for your first contribution! (some Symfony experience may be required)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp