Skip to content

ReloadPortals dosent work in the Admin #976

@umyetnik

Description

@umyetnik

Hey Guys

Trying to make conditional Felds.

if something is set on Field A then post a Autosave and Field B should appear.
`
categoryAdmin.RegisterEventFunc("autosave_Type", func(ctx *web.EventContext) (web.EventResponse, error) {
id := ctx.R.FormValue("ID")

	var category Category
	if err := postgresql.MainPostgresDataBase.Where("id = ?", id).First(&category).Error; err != nil {
		return web.EventResponse{}, err
	}
	newValue := ctx.R.FormValue("Type")
	category.Type = newValue
	if err := postgresql.MainPostgresDataBase.Save(&category).Error; err != nil {
		return web.EventResponse{}, err
	}
	return web.EventResponse{
		// Reload: true,
		ReloadPortals: []string{"reload"}, 
	}, nil

})

`

Autosave works fine and i got also a json Response after changing the value:

But the problematic part is this one:
`

	categoryAdmin.Editing().Field("Parent").ComponentFunc(
		func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) htmlgo.HTMLComponent {
			cat, ok := obj.(*Category)
			if !ok || cat.Type != "subCategory" {
				return nil
			}
			return web.Portal(
				func() htmlgo.HTMLComponent {
					if cat.Type != "subCategory" {
						return nil // oder ggf. Placeholder
					}
					return vuetify.VSelect().Label("Parent")
				}(),
			).Name("reload")
		})

`

if i reload manually the mechanism works fine - so the parentfield is just visible it the type is subcategory.

but the problem is nowhere in my dome some kind of portal with my name is visible and it also not refresh on change

Metadata

Metadata

Assignees

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