diff --git a/lib/api_form.dart b/lib/api_form.dart index b38b55b3..ff827598 100644 --- a/lib/api_form.dart +++ b/lib/api_form.dart @@ -558,6 +558,9 @@ class APIFormField { popupItemBuilder: (context, item, isSelected) { return _renderRelatedField(item, isSelected, true); }, + emptyBuilder: (context, item) { + return _renderEmptyResult(); + }, onSaved: (item) { if (item != null) { data["value"] = item["pk"]; @@ -650,9 +653,21 @@ class APIFormField { subtitle: Text("Model '${model}' rendering not supported"), ); } - } + // Construct a widget to instruct the user that no results were found + Widget _renderEmptyResult() { + return ListTile( + leading: FaIcon(FontAwesomeIcons.search), + title: Text(L10().noResults), + subtitle: Text( + L10().queryNoResults, + style: TextStyle(fontStyle: FontStyle.italic), + ), + ); + } + + // Construct a string input element Widget _constructString() { diff --git a/lib/widget/location_display.dart b/lib/widget/location_display.dart index b99c8077..75554e1a 100644 --- a/lib/widget/location_display.dart +++ b/lib/widget/location_display.dart @@ -170,7 +170,7 @@ class _LocationDisplayState extends RefreshableState { int pk = location?.pk ?? -1; - if (pk <= 0) { + if (location != null && pk <= 0) { return; } @@ -178,7 +178,7 @@ class _LocationDisplayState extends RefreshableState { context, L10().stockItemCreate, data: { - "location": pk, + "location": location != null ? pk : null, }, onSuccess: (result) async {