Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions development/components/database/objectmodel.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Field type is an important setting, it determines how ObjectModel will format yo
#### Validation rules reference

Several validation rules are available for your ObjectModel fields.
[Please refer to the Validate class of PrestaShop](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/classes/Validate.php) for a complete list.
[Please refer to the Validate class of PrestaShop](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/classes/Validate.php) for a complete list.

### Add timestamps to your entity (date_add and date_upd)

Expand Down Expand Up @@ -208,7 +208,7 @@ $cms->save();

In this example, we create an entity from scratch. Then, we set its `position` attribute, and we call the `save()` method. The `save()` method will trigger the `add()` method since its `id` attribute is not yet known (because the entity is not created in database).

If the insert is successful, the ObjectModel class will set the entity's id (retrieved from the database). [Complete reference here](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/classes/ObjectModel.php#L572-L658).
If the insert is successful, the ObjectModel class will set the entity's id (retrieved from the database). [Complete reference here](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/classes/ObjectModel.php#L483-L576).


### Load and save an object
Expand All @@ -221,7 +221,7 @@ $cms->position = 3;
$cms->save();
```

In this example, we retrieve an entity from the database with its id. Then, we change its `position` attribute and call the same `save()` method. The `save()` method will trigger the `update()` method and not the `add()` method since its `id` attribute is known. [Complete reference here](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/classes/ObjectModel.php#L750-L868).
In this example, we retrieve an entity from the database with its id. Then, we change its `position` attribute and call the same `save()` method. The `save()` method will trigger the `update()` method and not the `add()` method since its `id` attribute is known. [Complete reference here](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/classes/ObjectModel.php#L671-L750).

### Hard or soft delete an object

Expand Down Expand Up @@ -572,7 +572,7 @@ public function hookActionObjectProductDeleteAfter(Product $product)

Here is the reference of the methods described on this page. Many other methods that we don't described here are available.

See complete implementation here : [ObjectModel.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/classes/ObjectModel.php)
See complete implementation here : [ObjectModel.php](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/classes/ObjectModel.php)

```php
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: 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)
- Reference: [AmountCurrencyType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/AmountCurrencyType.php)

## Type options

Expand All @@ -20,7 +20,7 @@ Amount with currency: combination of a `NumberType` input and a `ChoiceType` inp

## Code example

- [OrderPaymentType.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderPaymentType.php#L113-L122)
- [OrderPaymentType.php](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderPaymentType.php#L93-L106)

```php
$builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: ButtonCollectionType
`ButtonCollectionType` is a form type used to group buttons in a common form group, which is useful for forms that have multiple submit buttons.

- Namespace: `PrestaShopBundle\Form\Admin\Type`
- Reference: [ButtonCollectionType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/ButtonCollectionType.php)
- Reference: [ButtonCollectionType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/ButtonCollectionType.php)

## Type options

Expand All @@ -20,14 +20,15 @@ title: ButtonCollectionType

## Code example

- [CombinationItemType.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Sell/Product/Combination/CombinationItemType.php#L150-L183)
- [CombinationItemType.php](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Sell/Product/Combination/CombinationItemType.php#L128-L222)

```php
$builder->add('actions', ButtonCollectionType::class, [
'buttons' => [
'edit' => [
'type' => IconButtonType::class,
'options' => [
'label' => $this->trans('Edit', 'Admin.Actions'),
'icon' => 'mode_edit',
'attr' => [
'class' => 'edit-combination-item tooltip-link',
Expand All @@ -39,6 +40,7 @@ $builder->add('actions', ButtonCollectionType::class, [
'delete' => [
'type' => IconButtonType::class,
'options' => [
'label' => $this->trans('Delete', 'Admin.Actions'),
'icon' => 'delete',
'attr' => [
'class' => 'delete-combination-item tooltip-link',
Expand All @@ -48,6 +50,7 @@ $builder->add('actions', ButtonCollectionType::class, [
'data-modal-cancel' => $this->trans('Cancel', 'Admin.Actions'),
'data-toggle' => 'pstooltip',
'data-original-title' => $this->trans('Delete', 'Admin.Actions'),
'data-shop-id' => $this->contextShopId,
],
],
],
Expand All @@ -56,6 +59,8 @@ $builder->add('actions', ButtonCollectionType::class, [
'attr' => [
'class' => 'combination-row-actions',
],
'inline_buttons_limit' => self::INLINE_ACTIONS_LIMIT,
'use_inline_labels' => false,
])
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: ColorPickerType
This form class is responsible for creating a color picker field

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [ColorPickerType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/ColorPickerType.php)
- Reference: [ColorPickerType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/ColorPickerType.php)

## Type options

Expand All @@ -16,11 +16,13 @@ This form class is responsible for creating a color picker field

## Code example

- [OrderStateType.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Configure/ShopParameters/OrderStates/OrderStateType.php#L132-L134)
- [OrderStateType.php](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Configure/ShopParameters/OrderStates/OrderStateType.php#L158-L162)

```php
$builder->add('color', ColorPickerType::class, [
'required' => true,
'required' => false,
'label' => $this->trans('Color', 'Admin.Shopparameters.Feature'),
'help' => $this->trans('Background color of this status label. Used both in backoffice and on order tracking page. HTML colors only.', 'Admin.Shopparameters.Help'),
])
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: ConfigurableCountryChoiceType
Class responsible for providing configurable countries list

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [ConfigurableCountryChoiceType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/ConfigurableCountryChoiceType.php)
- Reference: [ConfigurableCountryChoiceType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/ConfigurableCountryChoiceType.php)

## Type options

Expand All @@ -16,7 +16,7 @@ Class responsible for providing configurable countries list

## Code example

- [StateGridDefinitionFactory.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Grid/Definition/Factory/StateGridDefinitionFactory.php#L210-L218)
- [StateGridDefinitionFactory.php](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/Core/Grid/Definition/Factory/StateGridDefinitionFactory.php#L191-L199)

```php
$builder->add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: CustomContentType
Type is used to add any content at any position of the form, rather than the actual field.

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [CustomContentType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/CustomContentType.php)
- Reference: [CustomContentType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/CustomContentType.php)

## Type options

Expand All @@ -16,7 +16,7 @@ Type is used to add any content at any position of the form, rather than the act

## Code example

- [CmsPageType.php](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Improve/Design/Pages/CmsPageType.php#L142-L149)
- [CmsPageType.php](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Improve/Design/Pages/CmsPageType.php#L120-L130)

```php
$builder->add('seo_preview', CustomContentType::class, [
Expand All @@ -26,6 +26,9 @@ $builder->add('seo_preview', CustomContentType::class, [
'data' => [
'cms_url' => $options['cms_preview_url'],
],
'row_attr' => [
'class' => 'seo_preview',
],
])
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: DeltaQuantityType
Quantity field that displays the initial quantity (not editable) and allows editing with delta quantity instead (ex: +5, -8). The input data of this form type is the initial (as a plain integer) however, its output on submit is the delta quantity.

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [DeltaQuantityType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/DeltaQuantityType.php)
- Reference: [DeltaQuantityType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/DeltaQuantityType.php)

## Type options

Expand All @@ -16,7 +16,7 @@ Quantity field that displays the initial quantity (not editable) and allows edit

## Code example

- [BulkCombinationStockType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Sell/Product/Combination/BulkCombinationStockType.php#L78-L86)
- [BulkCombinationStockType](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Sell/Product/Combination/BulkCombinationStockType.php#L52-L61)

```php
$builder->add('delta_quantity', DeltaQuantityType::class, [
Expand All @@ -27,6 +27,7 @@ $builder->add('delta_quantity', DeltaQuantityType::class, [
'disabled_value' => function (?array $data) {
return empty($data['quantity']) && empty($data['delta']);
},
'modify_all_shops' => true,
])
```

Expand Down
5 changes: 3 additions & 2 deletions development/components/form/types-reference/email-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: EmailType
Symfony native EmailType extended with IDNConverter (InternationalizedDomainNameConverter) feature

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [EmailType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/EmailType.php)
- Reference: [EmailType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/EmailType.php)

## Type options

Expand All @@ -16,10 +16,11 @@ Symfony native EmailType extended with IDNConverter (InternationalizedDomainName

## Code example

- [EmployeeType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Configure/AdvancedParameters/Employee/EmployeeType.php#L136-L144)
- [EmployeeType](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Configure/AdvancedParameters/Employee/EmployeeType.php#L140-L149)

```php
$builder->add('email', EmailType::class, [
'label' => $this->trans('Email address', [], 'Admin.Global'),
'constraints' => [
$this->getNotBlankConstraint(),
$this->getLengthConstraint(EmployeeEmail::MAX_LENGTH),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: EntitySearchInputType
This form type is used for an OneToMany (or ManyToMany) association, it allows to search a list of entities (based on a remote URL) and associate it. It is based on the CollectionType form type which provides prototype features to display a custom template for each associated item.

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [EntitySearchInputType](https://github.com/PrestaShop/PrestaShop/blob/9.0.x/src/PrestaShopBundle/Form/Admin/Type/EntitySearchInputType.php)
- Reference: [EntitySearchInputType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/EntitySearchInputType.php)

## Type options

Expand All @@ -30,7 +30,7 @@ Learn more about [JavaScript components and how to use them]({{<relref "/9/devel

## Code example

- [RedirectOptionType](https://github.com/PrestaShop/PrestaShop/blob/9.0.x/src/PrestaShopBundle/Form/Admin/Sell/Category/SEO/RedirectOptionType.php#L86-L96)
- [RedirectOptionType](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Sell/Category/SEO/RedirectOptionType.php#L66-L76)

```php
$builder
Expand Down Expand Up @@ -63,7 +63,7 @@ let searchInput = new window.prestashop.component.EntitySearchInput(elementId, {
},
onSelectedContent: () => {
console.log('Event on product selection');
}
},
});
```

Expand Down
30 changes: 19 additions & 11 deletions development/components/form/types-reference/icon-button-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: IconButtonType
A form button with material icon.

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [IconButtonType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/IconButtonType.php)
- Reference: [IconButtonType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/IconButtonType.php)

## Type options

Expand All @@ -18,18 +18,26 @@ A form button with material icon.

## Code example

- [FooterType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Sell/Product/FooterType.php#L99-L107)
- [FooterType](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Sell/Product/FooterType.php#L102-L116)

```php
$builder->add('catalog', IconButtonType::class, [
'label' => $this->trans('Go to catalog', 'Admin.Catalog.Feature'),
'type' => 'link',
'icon' => 'arrow_back_ios',
'attr' => [
'class' => 'btn-outline-secondary border-white go-to-catalog-button',
'href' => $this->router->generate('admin_products_v2_index', ['offset' => 'last', 'limit' => 'last']),
],
])
$builder
->add('actions', ButtonCollectionType::class, [
'buttons' => [
'catalog' => [
'type' => IconButtonType::class,
'options' => [
'label' => $this->trans('Go to catalog', 'Admin.Catalog.Feature'),
'type' => 'link',
'icon' => 'arrow_back_ios',
'attr' => [
'class' => 'btn-outline-secondary go-to-catalog-button',
'href' => $this->router->generate('admin_products_index', ['offset' => 'last', 'limit' => 'last']),
],
],
],
],
])
```

## Preview example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: ImagePreviewType
This form type is used to display an image value without providing an interactive input to edit it. It is based on a hidden input so it could be changed programmatically, or used just to display an image in a form.

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [ImagePreviewType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/ImagePreviewType.php)
- Reference: [ImagePreviewType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/ImagePreviewType.php)

## Type options

Expand All @@ -18,7 +18,7 @@ This form type is used to display an image value without providing an interactiv

## Code example

- [HeaderType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Sell/Product/HeaderType.php#L79-L81)
- [HeaderType](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Sell/Product/HeaderType.php#L70-L72)

```php
$builder->add('cover_thumbnail', ImagePreviewType::class, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: LogSeverityChoiceType
ChoiceType of PrestaShopLogger Log levels

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [LogSeverityChoiceType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/LogSeverityChoiceType.php)
- Reference: [LogSeverityChoiceType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/LogSeverityChoiceType.php)

## Type options

Expand All @@ -16,7 +16,7 @@ ChoiceType of PrestaShopLogger Log levels

## Code example

- [LogsByEmailType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Configure/AdvancedParameters/Logs/LogsByEmailType.php#L46-L59)
- [LogsByEmailType](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Configure/AdvancedParameters/Logs/LogsByEmailType.php#L25-L39)

```php
$builder->add('logs_by_email', LogSeverityChoiceType::class, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: PriceReductionType
Responsible for creating form for price reduction

- Namespace: PrestaShopBundle\Form\Admin\Type
- Reference: [PriceReductionType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/PriceReductionType.php)
- Reference: [PriceReductionType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/PriceReductionType.php)

## Type options

Expand All @@ -16,7 +16,7 @@ Responsible for creating form for price reduction

## Code example

- [CatalogPriceRuleType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Sell/CatalogPriceRule/CatalogPriceRuleType.php#L190-L205)
- [CatalogPriceRuleType](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/PrestaShopBundle/Form/Admin/Sell/CatalogPriceRule/CatalogPriceRuleType.php#L136-L151)

```php
$builder->add('reduction', PriceReductionType::class, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: ProfileChoiceType
Class ProfileChoiceType is choice type for selecting employee's profile.

- Namespace: PrestaShopBundle\Form\Admin\Type\Common\Team
- Reference: [ProfileChoiceType](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/PrestaShopBundle/Form/Admin/Type/Common/Team/ProfileChoiceType.php)
- Reference: [ProfileChoiceType](https://github.com/PrestaShop/PrestaShop/blob/9.1.x/src/PrestaShopBundle/Form/Admin/Type/Common/Team/ProfileChoiceType.php)

## Type options

Expand All @@ -16,7 +16,7 @@ Class ProfileChoiceType is choice type for selecting employee's profile.

## Code example

- [EmployeeGridDefinitionFactory](https://github.com/PrestaShop/PrestaShop/blob/8.0.x/src/Core/Grid/Definition/Factory/EmployeeGridDefinitionFactory.php#L203-L209)
- [EmployeeGridDefinitionFactory](https://github.com/PrestaShop/PrestaShop/blob/9.1.0/src/Core/Grid/Definition/Factory/EmployeeGridDefinitionFactory.php#L183-L189)

```php
->add(
Expand Down
Loading
Loading