loadForm method
Fills the form: empty for item == null, otherwise with the full bed (photos included).
Implementation
Future<void> loadForm(UDormBedResponse? item) async {
final UDormBedResponse? b = item == null
? null
: (await UServices.hotel.readDormBedById(
p: UIdParams(
id: item.id,
selectorArgs: const UDormBedSelectorArgs(media: UMediaSelectorArgs()),
),
)).$1?.result ??
item;
editing = b;
formRoom = b?.room ?? item?.room ?? room;
titleController.text = b?.title ?? "";
depositController.text = b?.deposit.toInt().toString() ?? "";
rentController.text = b?.monthlyRent.toInt().toString() ?? "";
descriptionController.text = b?.jsonData.description ?? b?.jsonData.detail1 ?? "";
tags = List<int>.from(b?.tags ?? <int>[TagDormBed.single.number]);
media = (b?.media ?? <UMediaResponse>[]).sortedForGallery();
photos.dispose();
photos = UFilePickerController.fromMedia(media);
}