Skip to content

Commit

Permalink
Merge pull request #169 from torniker/ponzu-dev
Browse files Browse the repository at this point in the history
fixed problem with saving multiple repeaters closes #59 closes #167
  • Loading branch information
nilslice authored Jun 26, 2017
2 parents f4c5d79 + efbc295 commit fb56605
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions system/admin/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1851,15 +1851,16 @@ func editHandler(res http.ResponseWriter, req *http.Request) {
// and correctly format for db storage. Essentially, we need
// fieldX.0: value1, fieldX.1: value2 => fieldX: []string{value1, value2}
fieldOrderValue := make(map[string]map[string][]string)
ordVal := make(map[string][]string)
for k, v := range req.PostForm {
if strings.Contains(k, ".") {
fo := strings.Split(k, ".")

// put the order and the field value into map
field := string(fo[0])
order := string(fo[1])
fieldOrderValue[field] = ordVal
if len(fieldOrderValue[field]) == 0 {
fieldOrderValue[field] = make(map[string][]string)
}

// orderValue is 0:[?type=Thing&id=1]
orderValue := fieldOrderValue[field]
Expand Down
5 changes: 3 additions & 2 deletions system/api/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ func createContentHandler(res http.ResponseWriter, req *http.Request) {
// and correctly format for db storage. Essentially, we need
// fieldX.0: value1, fieldX.1: value2 => fieldX: []string{value1, value2}
fieldOrderValue := make(map[string]map[string][]string)
ordVal := make(map[string][]string)
for k, v := range req.PostForm {
if strings.Contains(k, ".") {
fo := strings.Split(k, ".")

// put the order and the field value into map
field := string(fo[0])
order := string(fo[1])
fieldOrderValue[field] = ordVal
if len(fieldOrderValue[field]) == 0 {
fieldOrderValue[field] = make(map[string][]string)
}

// orderValue is 0:[?type=Thing&id=1]
orderValue := fieldOrderValue[field]
Expand Down
5 changes: 3 additions & 2 deletions system/api/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ func updateContentHandler(res http.ResponseWriter, req *http.Request) {
// and correctly format for db storage. Essentially, we need
// fieldX.0: value1, fieldX.1: value2 => fieldX: []string{value1, value2}
fieldOrderValue := make(map[string]map[string][]string)
ordVal := make(map[string][]string)
for k, v := range req.PostForm {
if strings.Contains(k, ".") {
fo := strings.Split(k, ".")

// put the order and the field value into map
field := string(fo[0])
order := string(fo[1])
fieldOrderValue[field] = ordVal
if len(fieldOrderValue[field]) == 0 {
fieldOrderValue[field] = make(map[string][]string)
}

// orderValue is 0:[?type=Thing&id=1]
orderValue := fieldOrderValue[field]
Expand Down
5 changes: 3 additions & 2 deletions system/db/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ func SetConfig(data url.Values) error {
// and correctly format for db storage. Essentially, we need
// fieldX.0: value1, fieldX.1: value2 => fieldX: []string{value1, value2}
fieldOrderValue := make(map[string]map[string][]string)
ordVal := make(map[string][]string)
for k, v := range data {
if strings.Contains(k, ".") {
fo := strings.Split(k, ".")

// put the order and the field value into map
field := string(fo[0])
order := string(fo[1])
fieldOrderValue[field] = ordVal
if len(fieldOrderValue[field]) == 0 {
fieldOrderValue[field] = make(map[string][]string)
}

// orderValue is 0:[?type=Thing&id=1]
orderValue := fieldOrderValue[field]
Expand Down

0 comments on commit fb56605

Please sign in to comment.