toFormBuildDropDownCodeField method

String toFormBuildDropDownCodeField(
  1. SqfEntityFieldRelationshipBase field
)

Implementation

String toFormBuildDropDownCodeField(SqfEntityFieldRelationshipBase field) {
  final ccName = toCamelCase(field.fieldName);
  return '''void buildDropDownMenuFor$ccName() async {
    final dropdownMenuItems =
        await ${field.relationshipName}().select().toDropDownMenuInt('${field.formDropDownTextField}');
    setState(() {
      _dropdownMenuItemsFor$ccName = dropdownMenuItems;
      _selected$ccName = ${table.tableName!.toLowerCase()}.${field.fieldName};
    });
  }
  if (_dropdownMenuItemsFor$ccName.isEmpty) {
    buildDropDownMenuFor$ccName();
  }
  void onChangeDropdownItemFor$ccName(${field.table!.primaryKeyTypes[0]}? selected$ccName) {
    setState(() {
      _selected$ccName = selected$ccName;
    });
  }''';
}