Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChoiceWidget titles not pulling through #7

Closed
kylemartin87 opened this issue Mar 9, 2017 · 3 comments
Closed

ChoiceWidget titles not pulling through #7

kylemartin87 opened this issue Mar 9, 2017 · 3 comments

Comments

@kylemartin87
Copy link

Hi there

The ChoiceWidget does not appear to make use of the titles passed in through the Liform schema. The problem is that it is looking within the overall schema array and not within the liform element of the schema array.

This is what the Liform generated array looks like:

{  
   "title":"updaterbundle_announcement",
   "type":"object",
   "properties":{  
      "announcement":{  
         "type":"string",
         "title":"announcement",
         "attr":{  
            "placeholder":"Enter line update ..."
         },
         "default":"Enter line update ...",
         "required":[  
            "announcement"
         ],
         "widget":"textarea",
         "propertyOrder":1
      },
      "announcementType":{  
         "enum":[  
            "",
            "1",
            "2",
            "3"
         ],
         "liform":{  
            "enum_titles":[  
               "-- Choose --",
               "One",
               "Two",
               "Three"
            ]
         },
         "type":"string",
         "title":"Category",
         "required":[  
            "announcementType"
         ],
         "propertyOrder":2
      },
      "lineId":{  
         "type":"string",
         "title":"lineId",
         "attr":{  
            "maxlength":255
         },
         "maxLength":255,
         "propertyOrder":3
      }
   },
   "required":[  
      "announcement",
      "announcementType"
   ]
}

As you can see from the above, the "enum_titles" element is a child of "liform" and not the overall field schema ("announcementType" in this example).

I believe that by changing this line within the ChoiceWidget

var optionNames = field.schema.enum_titles || options;

to

var optionNames = field.schema.liform.enum_titles || options;

will fix the issue.

Thanks!

@nacmartin
Copy link
Member

Thanks for the report!

Hehe, I did again the fix in the PHP repo :). The reason is that at the beginning I started to put all the non standard json schema properties in a liform subarray, but then I decided not to do so anymore, because... for starters liform itself was non standard. Also, json schema validators validate correctly schemas with additional properties, and the standard itself says that anything a json schema parser cannot understand should be ignored.

But it looks like I forgot about this one. So thank you for finding it :) I will make a new release of liform in minutes, but it is fixed in master.

@nacmartin
Copy link
Member

@kylemartin87
Copy link
Author

Apologies for delay in responding!

Fix works perfectly. Really appreciate the great support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants