Skip to content

Commit

Permalink
Merge pull request #1756 from thomasnares/exampleNavigationTabType
Browse files Browse the repository at this point in the history
Document NavigationTabType
  • Loading branch information
kpodemski authored Dec 5, 2023
2 parents 9178d0c + 3cfab6f commit fc98766
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions development/components/form/types-reference/navigation-tab-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,54 @@ This form type is used as a container of sub forms, each sub form will be render

| Option | Type | Default value | Description |
| :----------- | :----- | :-------------------------------- | :---------------------------------------------------------------------------------------- |

## Usage and description

This form type [was introduced in {{< minver v="8.1.0">}}](https://github.com/PrestaShop/PrestaShop/pull/28752) in the new product page.

The new product page is based on this form type.

Its usage has been documented in an example module: [`demoproductform`](https://github.com/PrestaShop/example-modules/tree/master/demoproductform).

The module hooks to `actionProductFormBuilderModifier` to modify the `FormBuilder` for the Product page.
The `ProductFormModifier` adds a new `CustomTabType` (created by the module) to the `FormBuilder` (which is a `NavigationTabType`).

```php
$this->formBuilderModifier->addAfter(
$productFormBuilder,
'pricing',
'custom_tab',
CustomTabType::class,
[
'data' => [
'custom_price' => $customProduct->custom_price,
],
]
);
```

This `CustomTabType` contains a simple form type:

```php
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
$builder
->add('custom_price', MoneyType::class, [
'label' => $this->trans('My custom price', 'Modules.Demoproductform.Admin'),
'label_tag_name' => 'h3',
'currency' => $this->defaultCurrency->iso_code,
'required' => false,
'constraints' => [
new NotBlank(),
new Type(['type' => 'float']),
new PositiveOrZero(),
],
])
;
}
```

Preview of how it looks in the back office:

{{< figure src="../img/navigation-tab-type.png" title="NavigationTabType" >}}

0 comments on commit fc98766

Please sign in to comment.