Skip to content

Commit fd0450f

Browse files
committed
simplify example and remove duplication of query in widget-config (it seems to be not needed)
1 parent 59336b3 commit fd0450f

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

docs/backend/relations.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ This makes it very flexible for limiting relateable items by type, path, date, a
144144

145145
Setting the mode of the widget to `search` makes it easier to select from the content that result form your catalog-query instead of having to navigate through your content-tree.
146146

147-
The problem is that in the default mode of the Related Items wisget items that are in container s are not shown unless you add thes types of contaibers to the query.
147+
The problem is that in the default mode of the Related Items widget items that are in containers are not shown unless you add these types of containers to the query.
148148

149149
Therefore is is recommended to use CatalogSource only in in `search` mode.
150150

@@ -257,7 +257,7 @@ class IHaveMinions(model.Schema):
257257

258258
## RelationFields through the web or in xml
259259

260-
It is surprisingly easy to create RelationFields through the web
260+
It is surprisingly easy to create RelationFields through the web.
261261

262262
- Using the Dexterity schema editor, add a new field and select _Relation List_ or _Relation Choice_, depending on whether you want to relate to multiple items or not.
263263
- When configuring the field you can even select the content type the relation should be limited to.
@@ -301,7 +301,7 @@ RelationList:
301301
Support for `StaticCatalogVocabulary` in Volto is currently still missing.
302302
```
303303

304-
Often the standard widget for relations is not what you want since it can be hard to navigate to the content you want to relate to.
304+
Often the standard widget for relations is not what you want since it can be hard to navigate to the content you want to relate to and the search-mode of the default widget is not suitable for all use-cases.
305305

306306
If you want to use checkboxes, radiobuttons or a selection-dropdown you need to use `StaticCatalogVocabulary` instead of `CatalogSource` to specify your options.
307307

@@ -317,10 +317,7 @@ from z3c.relationfield.schema import RelationChoice
317317
relationchoice_field_select = RelationChoice(
318318
title="RelationChoice with Select Widget",
319319
vocabulary=StaticCatalogVocabulary(
320-
{
321-
"portal_type": ["Document", "Event"],
322-
"review_state": "published",
323-
}
320+
{"portal_type": ["Document", "Event"]}
324321
),
325322
required=False,
326323
)
@@ -351,23 +348,18 @@ relationlist_field_ajax_select = RelationList(
351348
{
352349
"portal_type": ["Document", "Event"],
353350
"review_state": "published",
354-
}
351+
},
352+
title_template="{brain.Type}: {brain.Title} at {path}", # Custom item rendering!
355353
)
356354
),
357355
required=False,
358356
)
359357
directives.widget(
360358
"relationlist_field_ajax_select",
361359
AjaxSelectFieldWidget,
362-
vocabulary=StaticCatalogVocabulary(
363-
{
364-
"portal_type": ["Document", "Event", "Folder"],
365-
},
366-
title_template="{brain.Type}: {brain.Title} at {path}",
367-
), # Custom item rendering
368-
pattern_options={ # Options for Select2
369-
"minimumInputLength": 2, # - Don't query until at least two characters have been typed
370-
"ajax": {"quietMillis": 500}, # - Wait 500ms after typing to make query
360+
pattern_options={ # Some options for Select2
361+
"minimumInputLength": 2, # Don't query until at least two characters have been typed
362+
"ajax": {"quietMillis": 500}, # Wait 500ms after typing to make query
371363
},
372364
)
373365
```

0 commit comments

Comments
 (0)