-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1713 from thomasnares/missingTypes
Table listing of custom form types
- Loading branch information
Showing
2 changed files
with
99 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
development/components/form/types-reference/amount-currency.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: AmountCurrencyType | ||
--- | ||
|
||
# AmountCurrencyType | ||
|
||
Amount with currency: combination of a `NumberType` input and a `ChoiceType` input (for currency selection). | ||
|
||
- Namespace: `PrestaShopBundle\Form\Admin\Type` | ||
- Reference: [AmountCurrencyType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/AmountCurrencyType.php) | ||
|
||
## Type options | ||
|
||
| Option | Type | Default value | Description | | ||
| :----------- | :----- | :-------------------------------- | :---------------------------------------------------------------------------------------- | | ||
| label | `boolean` | `false` | | | ||
| amount_constraints | `string` | `[]` | | | ||
| inherit_data | `boolean` | `true` | | | ||
| currencies | `array` | `[]` | | | ||
|
||
## Code example | ||
|
||
- [OrderPaymentType.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderPaymentType.php#L113-L122) | ||
|
||
```php | ||
$builder | ||
->add('amount_currency', AmountCurrencyType::class, [ | ||
'amount_constraints' => [ | ||
new NotNull(), | ||
new GreaterThan([ | ||
'value' => 0, | ||
'message' => $this->translator->trans( | ||
'Invalid value: the payment must be a positive amount.', [], 'Admin.Notifications.Error' | ||
), | ||
]), | ||
], | ||
'currencies' => $this->currencySymbolByIdChoiceProvider->getChoices([ | ||
'id_shop' => $this->contextShopId, | ||
]), | ||
]) | ||
``` | ||
|