getkirby-v2 / panel

This is the deprecated admin panel for Kirby v2.
http://getkirby.com
Other
134 stars 70 forks source link

CamelCase not working in Blueprint #1145

Closed jdd2405 closed 3 years ago

jdd2405 commented 6 years ago

In my project I built a frontent form, where visitors can add a new entry. Those entries should be editable from the backend.

My Blueprint looks like this

...
  locations:
    label: Locations
    type: structure
    ...
    fields:
      ...
      ageMin:
        label: Altersuntergrenze
        type: number
      ageMax:
        label: Altersobergrenze
        type: number
      startTime:
        label: Startzeitpunkt
        type: text
      endTime:
        label: Ende
        type: text
      latLng:
        label: Koordinaten (Latitude/Longitude)
        type: text

My form in the frontend uses camelCase as well to store values. To display the values in a Google Map i fetch the values by ther attribute name in camelCase.

But as soon I change a Sturcture Entry in the backend which came in by the form in the frontend, old values are untouched but new values are added with attribute names in lowercase. Changes made this way do not affect the frontend output.

Example before change (values from frontend form)

jsname: Name region: "63" website: www.example.com latLng: 1.11111,2.22222 ageMin: "16" ageMax: "25" startTime: 14:00 endTime: 17:00 firstname: Bruce lastname: Willis email: bruce.willis@example.com tel: "+41848800800"

Example after change (values from backend form)

jsname: Name region: "63" website: www.example.com latLng: 1.11111,2.22222 ageMin: "16" ageMax: "25" startTime: 14:00 endTime: 17:00 firstname: Bruce lastname: Willis email: bruce.willis@example.com tel: "+41848800800" agemin: "18" agemax: "25" starttime: 14:00 endtime: 17:00 latlng: 1.11111,2.22222

The reason is in panel/app/src/panel/structure.php where the function array_change_key_case is used a few times.

I don't like to change all my attribute names to lowercase or snake_case since I find this uggly and means a huge effort to change all those code segments where i retreive or store these values.

jdd2405 commented 6 years ago

Since this bug is planned to fix in version 3 I suggest to add to the documentation that camelCase in structure field names in Blueprints are stored in lowercase attribute names when values are added from the backend.

jdd2405 commented 6 years ago

Furthermore I found out that displaying values from camelCase attribute names in the backend is not possible unless they are written in lowercase.

not working ageMin, ageMax, startTime, endTime are not displayed as rows.

entry:
          - jsname
          - region
          - website
          - firstname
          - lastname
          - email
          - tel
          - ageMin
          - ageMax
          - startTime
          - endTime

working

entry:
          - jsname
          - region
          - website
          - firstname
          - lastname
          - email
          - tel
          - agemin
          - agemax
          - starttime
          - endtime