Closed ger86 closed 3 years ago
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
I had a similar issue with conditions in configureFormFields. When autocomplete runs $this->getSubject()
is null. This is how I solved it:
/**
* {@inheritdoc}
*/
protected function configureFormFields(FormMapper $formMapper)
{
$editSubject = $this->id($this->getSubject());
//...
// Show only when edit or autocomplete items action
if ($editSubject || 'sonata_admin_retrieve_autocomplete_items' === $this->getRequest()->get('_route')) {
$formMapper
->add('myField', ModelAutocompleteType::class, [
//...
'callback' => [$this, 'myCallback'],
]);
//...
}
}
//...
}
I am experiencing exactly the same as the topic starter in combination with inherited class.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Environment
Sonata packages
Symfony packages
PHP version
Subject
I have a class HistoryRecord from which a class CollaboHistoryRecord inherits. I have declared and admin for class A in the following way:
In the admin I have the following in the configureFormFields method:
The problem happens when I try to use the autocomplete field: a 500 error happens with the following message:
Steps to reproduce
Expected results
Actual results