Sonata default filter valueSonata admin bundle orderSymfony2 - Give a default filter in a list of elements of Sonata AdminCustomize the Sonata Admin Dashboard - Sonata and Symfony 2Creating custom form type using sonata form type as parentSonata Admin Filter: Invalid parameter number: number of bound variables does not match number of tokenssonata admin custom list field (not from entity)sonata admin add richhtml editor to block contentSonata sort admin list using a aggregate on a child fieldSonata form field - change a field based on the selection of another model fieldSonata admin: mosaic selected by default
Would getting a natural 20 with a penalty still count as a critical hit?
What is the purpose/function of this power inductor in parallel?
How does Monero protect users from inflation bugs if the blockchain can't be audited?
Is there a word for returning to unpreparedness?
Is there a fallacy about "appeal to 'big words'"?
When did Bilbo and Frodo learn that Gandalf was a Maia?
Good way to stop electrolyte tabs from turning into powder?
What's the relationship betweeen MS-DOS and XENIX?
Why does this image of cyclocarbon look like a nonagon?
If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?
What should I do with the stock I own if I anticipate there will be a recession?
Setting up a Mathematical Institute of Refereeing?
Did Michelle Obama have a staff of 23; and Melania have a staff of 4?
Are there any cons in using rounded corners for bar graphs?
What allows us to use imaginary numbers?
Is a USB 3.0 device possible with a four contact USB 2.0 connector?
Attacking the Hydra
pester mode not working for showToastEvent in LWC
What should we do with manuals from the 80s?
What are some tips and tricks for finding the cheapest flight when luggage and other fees are not revealed until far into the booking process?
Minimum population for language survival
A Magic Diamond
May the tower use the runway while an emergency aircraft is inbound?
Physical Interpretation of an Overdamped Pendulum
Sonata default filter value
Sonata admin bundle orderSymfony2 - Give a default filter in a list of elements of Sonata AdminCustomize the Sonata Admin Dashboard - Sonata and Symfony 2Creating custom form type using sonata form type as parentSonata Admin Filter: Invalid parameter number: number of bound variables does not match number of tokenssonata admin custom list field (not from entity)sonata admin add richhtml editor to block contentSonata sort admin list using a aggregate on a child fieldSonata form field - change a field based on the selection of another model fieldSonata admin: mosaic selected by default
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a property in my method configureDatagridFilters()
called assignee. When the list view of my admin is first loaded, I'd like to set the value of this property to the current user.
I have tried:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser(),
];
return $parameters;
as well as an array_merge
instead. None of them achieved what I'm after, it still just shows me the default/entire list.
I have tried adding a type, bit unclear as to what the type is as some examples I've seen are like EntityType::class
and others just a number 3
.
symfony sonata-admin sonata symfony-sonata
add a comment |
I have a property in my method configureDatagridFilters()
called assignee. When the list view of my admin is first loaded, I'd like to set the value of this property to the current user.
I have tried:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser(),
];
return $parameters;
as well as an array_merge
instead. None of them achieved what I'm after, it still just shows me the default/entire list.
I have tried adding a type, bit unclear as to what the type is as some examples I've seen are like EntityType::class
and others just a number 3
.
symfony sonata-admin sonata symfony-sonata
add a comment |
I have a property in my method configureDatagridFilters()
called assignee. When the list view of my admin is first loaded, I'd like to set the value of this property to the current user.
I have tried:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser(),
];
return $parameters;
as well as an array_merge
instead. None of them achieved what I'm after, it still just shows me the default/entire list.
I have tried adding a type, bit unclear as to what the type is as some examples I've seen are like EntityType::class
and others just a number 3
.
symfony sonata-admin sonata symfony-sonata
I have a property in my method configureDatagridFilters()
called assignee. When the list view of my admin is first loaded, I'd like to set the value of this property to the current user.
I have tried:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser(),
];
return $parameters;
as well as an array_merge
instead. None of them achieved what I'm after, it still just shows me the default/entire list.
I have tried adding a type, bit unclear as to what the type is as some examples I've seen are like EntityType::class
and others just a number 3
.
symfony sonata-admin sonata symfony-sonata
symfony sonata-admin sonata symfony-sonata
asked Mar 27 at 12:18
MylesKMylesK
21512 bronze badges
21512 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
So I figured out how to set the filter by default to the current user.
My filter is an EntityType::class
with the class of User::class
. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId()
.
So the full method would be:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser()->getId(),
];
return $parameters;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377028%2fsonata-default-filter-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
So I figured out how to set the filter by default to the current user.
My filter is an EntityType::class
with the class of User::class
. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId()
.
So the full method would be:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser()->getId(),
];
return $parameters;
add a comment |
So I figured out how to set the filter by default to the current user.
My filter is an EntityType::class
with the class of User::class
. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId()
.
So the full method would be:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser()->getId(),
];
return $parameters;
add a comment |
So I figured out how to set the filter by default to the current user.
My filter is an EntityType::class
with the class of User::class
. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId()
.
So the full method would be:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser()->getId(),
];
return $parameters;
So I figured out how to set the filter by default to the current user.
My filter is an EntityType::class
with the class of User::class
. In order for the code snippet above to work, you must set the value to the user ID and not the user object like so: 'value' => $this->getUser()->getId()
.
So the full method would be:
public function getFilterParameters()
$parameters = parent::getFilterParameters();
$parameters['assignee'] = [
'value' => $this->getUser()->getId(),
];
return $parameters;
answered Mar 28 at 15:27
MylesKMylesK
21512 bronze badges
21512 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377028%2fsonata-default-filter-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown