interface icon indicating copy to clipboard operation
interface copied to clipboard

`<SelectField>`: `defaultValue` does not work as expected

Open Vrtak-CZ opened this issue 1 year ago • 3 comments

Hi, Let me simplify my problem.

I have this schema.

export class Category {
    name = def.stringColumn().notNull()
    articles = def.oneHasMany(Article, 'articles')
}

export class Article {
    name = def.stringColumn().notNull()
    category = def.manyHasOne(Category, 'articles')
}

Then I have this simple form

const ArticleForm = Component(
	() => (
		<>
			<TextField field="name" label="Name" />
			<SelectField field="category" label="Category" options="Category.name" defaultValue="62522664-1681-49a8-85c9-21998ef4158c" />
		</>
	),
)
export default () => (
	<CreatePage
		entity="Article"
	>
		<ArticleForm />
	</CreatePage>
)

This will not throw any error and also not "preselect" Category with id 62522664-1681-49a8-85c9-21998ef4158c.

Vrtak-CZ avatar Mar 20 '23 00:03 Vrtak-CZ