Skip to content

<SelectField>: defaultValue does not work as expected #474

@Vrtak-CZ

Description

@Vrtak-CZ

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions