Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlino committed Jan 13, 2020
1 parent d6fde8f commit a1eaed5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,50 @@ class Player extends DataObject

```

### Primary search field

In tabular views such as `GridField`, there is a monolithic search bar. By default, this will be the *first
field* in your `searchableFields` list.

As an example, let's look at a definition like this:

```php
private static $searchable_fields = [
'Name',
'JobTitle',
];
```

That `Name` comes first in that list is actually quite a good thing. The user will likely want the
single search input to target the `Name` field rather something with a more predictable value,
like `JobTitle`.

By contrast, let's look at this definition:

```php
private static $searchable_fields = [
'Price',
'Description',
'Title',
];
```

It's unlikely that the user will want to search on `Price`. A better candidate would be `Title` or `Description`. Rather than reorder the array, which is counter-intuitive, it is recommended
that you use the `primary_search_field` configuration property.

```php
private static $primary_search_field = 'Title';
```

#### Context-specific primary search field

If the primary search field is not universal, but rather, context-dependent, you can customise
the search field on the `GridFieldFilterHeader` component instance.

```php
$myGrid->getConfig()->getComponentByType(GridFieldFilterHeader::class)->setSearchField('Title');
```

### Summary Fields

Summary fields can be used to show a quick overview of the data for a specific [DataObject](api:SilverStripe\ORM\DataObject) record. The most common use
Expand Down
5 changes: 5 additions & 0 deletions docs/en/02_Developer_Guides/12_Search/01_Searchcontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ In case you need multiple contexts, consider name-spacing your request parameter
the `$fields` constructor parameter.
[/notice]

### Customising the primary search field

The monolithic search bar that is applied to tabular views in the CMS searches on field, unless
the advanced search options are exposed. To customise this field, see the [Scaffolding documentation](../model/scaffolding#context-specific-primary-search-field).

### Generating a search form from the context


Expand Down

0 comments on commit a1eaed5

Please sign in to comment.