Skip to content

Commit

Permalink
minor #36128 [Form][CheckboxType] Remove _false_is_empty flag (fancyweb)
Browse files Browse the repository at this point in the history
This PR was merged into the 5.1-dev branch.

Discussion
----------

[Form][CheckboxType] Remove _false_is_empty flag

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Cleanup of symfony/symfony#35938.

Commits
-------

6fac6d4086 [Form][CheckboxType] Remove _false_is_empty flag
  • Loading branch information
nicolas-grekas committed Mar 19, 2020
2 parents 71811fc + 1a26d37 commit a8640dc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion Extension/Core/Type/CheckboxType.php
Expand Up @@ -33,7 +33,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
// doing so also calls setDataLocked(true).
$builder->setData(isset($options['data']) ? $options['data'] : false);
$builder->addViewTransformer(new BooleanToStringTransformer($options['value'], $options['false_values']));
$builder->setAttribute('_false_is_empty', true); // @internal - A boolean flag to treat false as empty, see Form::isEmpty() - Do not rely on it, it will be removed in Symfony 5.1.
}

/**
Expand Down
4 changes: 1 addition & 3 deletions Form.php
Expand Up @@ -740,9 +740,7 @@ public function isEmpty()
// arrays, countables
((\is_array($this->modelData) || $this->modelData instanceof \Countable) && 0 === \count($this->modelData)) ||
// traversables that are not countable
($this->modelData instanceof \Traversable && 0 === iterator_count($this->modelData)) ||
// @internal - Do not rely on it, it will be removed in Symfony 5.1.
(false === $this->modelData && $this->config->getAttribute('_false_is_empty'));
($this->modelData instanceof \Traversable && 0 === iterator_count($this->modelData));
}

/**
Expand Down

0 comments on commit a8640dc

Please sign in to comment.