AddMessage adds the provided error, and if a non-empty names list is set, adds the error on the corresponding field.
(group node.UiNodeGroup, err *text.Message, setForFields ...string)
| 338 | // AddMessage adds the provided error, and if a non-empty names list is set, |
| 339 | // adds the error on the corresponding field. |
| 340 | func (c *Container) AddMessage(group node.UiNodeGroup, err *text.Message, setForFields ...string) { |
| 341 | if !slices.ContainsFunc(setForFields, func(s string) bool { return strings.TrimSpace(s) != "" }) { |
| 342 | c.Messages = append(c.Messages, *err) |
| 343 | return |
| 344 | } |
| 345 | |
| 346 | for _, name := range setForFields { |
| 347 | if ff := c.Nodes.Find(name); ff != nil { |
| 348 | ff.Messages = append(ff.Messages, *err) |
| 349 | continue |
| 350 | } |
| 351 | |
| 352 | n := node.NewInputField(name, nil, node.DefaultGroup, node.InputAttributeTypeText) |
| 353 | n.Messages = text.Messages{*err} |
| 354 | c.Nodes = append(c.Nodes, n) |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | func (c *Container) Scan(value interface{}) error { |
| 359 | return sqlxx.JSONScan(c, value) |