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 #6312 from TheMadeleine/docs/grid-bundle
[Documentation][Bundles] SyliusGridBundle docs update
- Loading branch information
Showing
14 changed files
with
347 additions
and
425 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,38 +1,42 @@ | ||
Configuration Reference | ||
======================= | ||
|
||
Here you will find all configuration options of ``sylius_grid``. | ||
|
||
.. code-block:: yaml | ||
sylius_grid: | ||
grids: | ||
app_user: # Your grid name. | ||
driver: doctrine/orm # Data source driver. | ||
resource: app.user # Resource name. | ||
app_user: # Your grid name | ||
driver: | ||
name: doctrine/orm # Data source driver | ||
options: | ||
class: AppBundle\Entity\user | ||
resource: app.user # Resource name | ||
sorting: | ||
name: asc | ||
columns: | ||
name: | ||
type: twig # Type of column. | ||
label: Name # Label. | ||
path: name | ||
direction: asc | ||
fields: | ||
name: | ||
type: twig # Type of field | ||
label: Name # Label | ||
path: name | ||
sortable: true | ||
options: | ||
template: :Grid/Column:_name.html.twig # Only twig column | ||
path: name | ||
sort: name | ||
filters: | ||
group: | ||
type: entity | ||
label: Group | ||
options: | ||
entity: AppBundle:Group | ||
name: | ||
type: string # Type of filter | ||
label: app.ui.name | ||
actions: | ||
edit: | ||
type: link | ||
options: | ||
route: app_user_update | ||
bulk_actions: | ||
delete: | ||
type: delete | ||
copy: | ||
type: copy | ||
main: | ||
create: | ||
type: create | ||
item: | ||
update: | ||
type: update | ||
delete: | ||
type: delete | ||
show: | ||
type: show |
This file was deleted.
Oops, something went wrong.
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,67 @@ | ||
Custom Field Type | ||
================= | ||
|
||
There are certain cases when built-in field types are not enough. Sylius Grids allows to define new types with ease! | ||
|
||
All you need to do is create your own class implementing FieldTypeInterface and register it as a service. | ||
|
||
.. code-block:: php | ||
<?php | ||
namespace AppBundle\Grid\FieldType; | ||
use Sylius\Component\Grid\Definition\Field; | ||
use Sylius\Component\Grid\FieldTypes\FieldTypeInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
class CustomType implements FieldTypeInterface | ||
{ | ||
public function render(Field $field, $data, array $options = []) | ||
{ | ||
// Your rendering logic... Use Twig, PHP or even external api... | ||
} | ||
public function configureOptions(OptionsResolver $resolver) | ||
{ | ||
$resolver | ||
->setDefaults([ | ||
'dynamic' => false | ||
]) | ||
->setAllowedTypes([ | ||
'dynamic' => ['boolean'] | ||
]) | ||
; | ||
} | ||
public function getName() | ||
{ | ||
return 'custom'; | ||
} | ||
} | ||
That is all. Now register your new field type as a service. | ||
|
||
.. code-block:: yaml | ||
# app/config/services.yml | ||
app.grid_field.custom: | ||
class: AppBundle\Grid\FieldType\CustomType | ||
tags: | ||
- { name: sylius.grid_field, type: custom } | ||
Now you can use your new column type in the grid configuration! | ||
|
||
.. code-block:: yaml | ||
sylius_grid: | ||
grids: | ||
app_admin_supplier: | ||
driver: | ||
name: doctrine/orm | ||
options: | ||
class: AppBundle\Entity\Supplier | ||
fields: | ||
name: | ||
type: custom | ||
label: sylius.ui.name |
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
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,26 @@ | ||
Field configuration | ||
=================== | ||
|
||
Each field can be configured with several configuration keys, to make it more suitable to your grid requirements. | ||
|
||
+------------+------------+-----------------------------------------------------------------------------------------------------------+ | ||
| Name | Type | Description | | ||
+============+============+===========================================================================================================+ | ||
| type | string | Type of column. Default field types are described :doc:`here </bundles/SyliusGridBundle/field_types>`. | | ||
+------------+------------+-----------------------------------------------------------------------------------------------------------+ | ||
| label | string | Label displayed in the field header. By default, it is field name. | | ||
+------------+------------+-----------------------------------------------------------------------------------------------------------+ | ||
| path | string | Path to property displayed in field (can be property of resource or one of its referenced objects). | | ||
+------------+------------+-----------------------------------------------------------------------------------------------------------+ | ||
| options | array | Array of field options (see below). | | ||
+------------+------------+-----------------------------------------------------------------------------------------------------------+ | ||
|
||
``options`` field can contains following fields: | ||
|
||
+------------+--------------+-------------------------------------------------------------------------------------------------------------+-------------+ | ||
| Name | Type | Description | Default | | ||
+============+==============+=============================================================================================================+=============+ | ||
| template | string | Available (and required) only for *twig* column type. Path to template that is used to render column value. | | | ||
+------------+--------------+-------------------------------------------------------------------------------------------------------------+-------------+ | ||
| format | string | Available only for *datetime* field type. | Y:m:d H:i:s | | ||
+------------+--------------+-------------------------------------------------------------------------------------------------------------+-------------+ |
Oops, something went wrong.