Hi,
I've tried using the standard Menu and SQL field types.
I've used the following XML code for the field
<field name="menu" type="menu" label="Menu" description="Select menu items to show"></field>
<field name="menu" type="sql" label="Menu" description="Select menu item to show" query="SELECT id as key, title as value FROM #__menu_types ORDER title ASC"></field>
I'm using it with the Joomlart ACM module in Joomla 4 in my template.
On both occasions I get the similar error back
Database not set in Joomla\CMS\Form\Field\MenuField
Database not set in Joomla\CMS\Form\Field\SQLField
I looked on github at the code in Joomla\CMS\Form\Field\MenuField and SQLField and the only thing I can see is $db = $this->getDatabase () ; referring to the database.
I believe something changed regarding the way joomla access the database now in Joomla 4? I presume that's what is causing the issue? Is the error in Joomlarts ACM module or Joomla 4 itself - all I can tell is that Joomlarts ACM module just seems to take the field XML information and uses it with Joomlafield anyway so I can't see it being an issue on their end.
I would make my own custom field but not sure where I'd put custom field code in a template and call the SQL myself through PHP (can you even define a custom field in a template?)