Symfony 4.2.2
sonata-project/admin-bundle 3.45.1 3.45.1 The missing Symfony A...
sonata-project/block-bundle 3.14.0 3.14.0 Symfony SonataBlockBu...
sonata-project/cache 2.0.1 2.0.1 Cache library
sonata-project/core-bundle 3.15.1 3.15.1 Symfony SonataCoreBundle
sonata-project/datagrid-bundle 2.4.0 2.4.0 Symfony SonataDatagri...
sonata-project/doctrine-extensions 1.1.5 1.1.5 Doctrine2 behavioral ...
sonata-project/doctrine-orm-admin-bundle 3.8.1 3.8.1 Symfony Sonata / Inte...
sonata-project/exporter 2.0.1 2.0.1 Lightweight Exporter ...
sonata-project/intl-bundle 2.5.0 2.5.0 Symfony SonataIntlBundle
PHP 7.2
One violation error on dashboard with stats block.
Add a block in sonata_admin package file :
blocks:
-
type: sonata.admin.block.stats
position: top
class: col-lg-6 col-xs-6
settings:
code: users
icon: fa-list-alt
text: users
color: bg-green
It will display a box on dashboard page but in sf toolbar, I have an error with my created form : _per_page is invalid : This value is not valid
In Datagrid.php, the form is automatically submitted, the field _per_page is present and the values pass to the form is ok : "_per_page" => ["type" => null, "value" => 1000].
The violation is a ConstraintViolation caused by a TransformationFailedException
i have the same probleme !!! any solution ?
Me to!!!!!!
up
Same error here
Thank you so much for the report @GCalmels!
Do you mind to work on this issue?
I tried to work on it by adding addViewTransformer and change the array to string but the transformer was never called in the submit function. I always have the TransformationFailedException from Form.php.
My snippet :
$this->formBuilder->get('_per_page')->addViewTransformer(new CallbackTransformer(
function ($value) {
return json_encode($value);
},
function ($value) {
return json_decode($value);
}
));
same problem
Maybe someone can work on a solution, otherwise the problem won't be solved. Posting same problem will not trigger a magic fairy that will solve the problem for you :trollface:
@GCalmels @tschackmack @VincentLanglet @tifed @msalmikais can you provide a PR?
oh, thats disappointing... I thought this could be some kind of magic spell ;))
Yes @core23, I have tried to find a solution and I posted a comment 23 days ago here because I didn't find any perfect solution...
Could you help me, please ?
I suppose (please note that I'm not that expirienced SonataUser)...
the problem happens in Block/AdminStatsBlockService line 43ff.
public function execute(BlockContextInterface $blockContext, Response $response = null)
{
$admin = $this->pool->getAdminByAdminCode($blockContext->getSetting('code'));
$datagrid = $admin->getDatagrid();
$filters = $blockContext->getSetting('filters');
if (!isset($filters['_per_page'])) {
$filters['_per_page'] = ['value' => $blockContext->getSetting('limit')];
}
foreach ($filters as $name => $data) {
$datagrid->setValue($name, $data['type'] ?? null, $data['value']);
}
$datagrid->buildPager();
return $this->renderPrivateResponse($blockContext->getTemplate(), [
'block' => $blockContext->getBlock(),
'settings' => $blockContext->getSettings(),
'admin_pool' => $this->pool,
'admin' => $admin,
'pager' => $datagrid->getPager(),
'datagrid' => $datagrid,
], $response);
}
here is created:
array:2 [â–¼
"type" => null
"value" => 1000
]
so if you just change the order
```php
foreach ($filters as $name => $data) {
$datagrid->setValue($name, $data['type'] ?? null, $data['value']);
}
if (!isset($filters['_per_page'])) {
$filters['_per_page'] = ['value' => $blockContext->getSetting('limit')];
}
you'll get (in my case) 2 filters and the error is gone
array:2 [â–¼
"isAktiv" => array:1 [â–¼
"value" => 0
]
"_per_page" => array:1 [â–¼
"value" => 1000
]
]
```
.. but as I told, I'm not a professional
Most helpful comment
Me to!!!!!!