Skip to content
Gx
GitHub

GX2011: dynamic URL attribute

href, src, action or formaction has a string expression as its value.

Cause

href, src, action or formaction has a string expression as its value. A string from data can hold a javascript: address.

Example

ui/card/Card.gx
package card

props {
  Link string
}

<a href={p.Link}>Read</a>

gx check reports:

gx check
ui/card/Card.gx:7:4: GX2011: attribute "href" needs a typed route or gx.URL, not a dynamic string

Fix

  1. For a page of the app, pass a route value, for example href={route.Show{ID: p.ID}}.
  2. For an address that is not in the app, pass a gx.URL value.