Skip to content

Commit

Permalink
BUG FIX: Fix add new link for fk
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedHardware committed Nov 27, 2018
1 parent 706f55a commit 585415d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion get_schema.go
Expand Up @@ -148,6 +148,9 @@ func getSchema(a interface{}) (s ModelSchema, ok bool) {
f.DisplayName = val
}

// Get the type name
f.TypeName = t.Field(index).Type.Name()

// Process the field's data type
if t.Field(index).Type == SType {
f.Type = "string"
Expand All @@ -172,7 +175,8 @@ func getSchema(a interface{}) (s ModelSchema, ok bool) {
if val, ok := t.FieldByName(t.Field(index).Name + "ID"); ok {
// Check if the FK field is a number
if val.Type == NType || val.Type == NType1 || val.Type == NType2 || val.Type == NType3 || val.Type == NType4 || val.Type == NType5 {
//f.FK = val.Name
// Remove the pointer if it is a foreign key
f.TypeName = strings.Trim(f.TypeName, "*")
} else {
Trail(ERROR, "Invalid FK %s.%s your %sID field is not an integer based number", t.Name(), t.Field(index).Name, t.Field(index).Name)
}
Expand Down
2 changes: 1 addition & 1 deletion global.go
Expand Up @@ -79,7 +79,7 @@ const cEMAIL = "email"
const cM2M = "m2m"

// Version number as per Semantic Versioning 2.0.0 (semver.org)
const Version = "0.1.0-beta.4"
const Version = "0.1.0-beta.5"

// Public Global Variables

Expand Down
1 change: 1 addition & 0 deletions schema.go
Expand Up @@ -35,6 +35,7 @@ type F struct {
Name string
DisplayName string
Type string
TypeName string
Value interface{}
Help string
Max interface{}
Expand Down
2 changes: 1 addition & 1 deletion templates/uadmin/default/form.html
Expand Up @@ -251,7 +251,7 @@
<option value="{{ .K }}"{{if .Selected}} selected{{end}}>{{ .V }}</option>
{{end}}
</select>
<a class="checkinventory camelcaseFixHrefID {{if $is_readonly}}hidden{{end}} no-style" href="{{$RootURL}}{{.Name}}ID">
<a class="camelcaseFixHrefID {{if $is_readonly}}hidden{{end}} no-style" href="{{$RootURL}}{{.TypeName}}ID">
<i class="fa fa-plus-circle"></i>&nbsp;add new
</a>
{{ if eq .Help "" }}{{ else }}<br /><span class="text-muted" style="font-size:12px;"><i class="fa fa-question-circle"></i> {{.Help}}</span>{{ end }}
Expand Down

0 comments on commit 585415d

Please sign in to comment.