silverstripe / silverstripe/developer-docs
function getSearchContext in extension of modeladmin is not called anymore
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 74
- Avg merge
- 1d 14m
- Merged PRs (30d)
- 6
Description
Affected Version
v4.3.0
Description
When extending ModelAdmin to add new pre-defined queries (e.g. a checkbox that will be used to filter adresses in Belgium - using later on the getlist function), the overwritten getSearchContext functions never called.
This is the code I used but you may simply use examples from your on-line developers doc (https://docs.silverstripe.org/en/4/developer_guides/customising_the_admin_interface/modeladmin/).
class Adress_Admin extends ModelAdmin {
private static $url_segment = 'Adress';
private static $menu_title = 'Adressen';
private static $managed_models = [Adress::class];
public function getSearchContext()
{
$context = parent::getSearchContext();
if($this->modelClass == 'bpf\Adress') {
$context->getFields()->push(new CheckboxField('q[InBelgiumA]', 'Only expensive stuff'));
}
return $context;
}
Steps to Reproduce
It's very easy to check - use e.g. error_log to trace the fact the function has been called.
Help us with step-by-step instructions.
ps: I know this will be depreciated in v5 but at least could you please provide an updated documentation on how to do it using GridfieldFilterHeader.
Thank you!!!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ModelAdmin customization documentation linked in the issue and review the reported getSearchContext example alongside the comment thread. Confirm the documented behavior for v4.3 and identify the current GridFieldFilterHeader approach. Done means the developer documentation explains the supported replacement, including enough steps for extending ModelAdmin and filtering managed records.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100