Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] [MoneyType] Add "input" option #50720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

BASAKSemih
Copy link
Contributor

@BASAKSemih BASAKSemih commented Jun 20, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #50707
License MIT
Doc PR - WIP

@carsonbot carsonbot added this to the 6.4 milestone Jun 20, 2023
@carsonbot carsonbot changed the title [Form][MoneyType] Add "format" options [Form] [MoneyType] Add "format" options Jun 20, 2023
@BASAKSemih BASAKSemih changed the title [Form] [MoneyType] Add "format" options [Form] [MoneyType] Add "input" option Jun 22, 2023
'currency' => 'EUR',
'compound' => false,
'html5' => false,
'scale' => 2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the codestyle changes have to be reverted

$this->assertSame(12345, $form->getData());
}

public function testInputTypeIntegerAndDivisorNotEgalToOne()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function testInputTypeIntegerAndDivisorNotEgalToOne()
public function testInputTypeIntegerAndDivisorNotEqualToOne()

public function testValueToIntegerWithSpecificOptionInputToInteger()
{
$form = $this->factory->create(static::TESTED_TYPE, null, ['input' => 'integer']);
$form->submit('12345.6');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this case should trigger an exception in during reverseTransform()


public function testHtml5EnablesSpecificFormattingWithIntegerFormat()
{
$form = $this->factory->create(static::TESTED_TYPE, null, ['html5' => true, 'scale' => 2, 'input' => 'integer']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that a scale option with a value other than 0 plays well with how the input option is implemented currently.

But, this makes me wonder if the way this option is currently implemented actually makes sense. So maybe we should indeed allow the division to be greater than 1 and take it into account to decide whether we want to render a number or an integer widget.

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this feature, but I wonder about the new option name: input sounds too generic.

Just wondering: since we have other options called model_* (e.g. model_timezone in nhttps://symfony.com/doc/current/reference/forms/types/datetime.html#model-timezone). Should we rename this option to follow that pattern? Some ideas:

model_formatting
model_format
model_data_type
...

@fabpot
Copy link
Member

fabpot commented Oct 1, 2023

@BASAKSemih Do you have time to take comments into account?

@BASAKSemih
Copy link
Contributor Author

@BASAKSemih Do you have time to take comments into account?

No sorry i don't have time

@fabpot
Copy link
Member

fabpot commented Oct 5, 2023

Thank you for your answer. Let’s close for now then. Maybe someone will take over.

@fabpot fabpot closed this Oct 5, 2023
@BASAKSemih BASAKSemih deleted the MoneyType/addFormatOption branch November 24, 2023 11:38
fabpot added a commit that referenced this pull request Dec 29, 2023
This PR was squashed before being merged into the 7.1 branch.

Discussion
----------

[Form] add "model_type" option to MoneyType

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #50707
| License       | MIT

This is a replacement for abandoned #50720

Please notice that the previous PR misunderstood the related issue: the intended casting should be applied when the divisor is not 1, otherwise it doesn't make sense.

Commits
-------

8811741 [Form] add "model_type" option to MoneyType
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new option to MoneyType
5 participants