Closed gastonche closed 6 years ago
We can already do this. If you have a property
'color': { 'type':'string', 'widget': 'color', 'title': 'In which color' },
It will look for the widget color
. If it was
'color': { 'type':'string', 'title': 'In which color' },
It would use the widget string
instead.
I was following the json-schema standards following this docs, and i believe it's going to be more standards to enable the format property too for this check given that most people may already have followed those standards and setup their schema with the format property.
Ok, it may be good idea:
If widget
is present, use widget
.
Otherwise: If format
is present, then use format
.
Otherwise: use type
.
Would that be ok?
Yes, that will be okay, I will clean up the code I have written for this and submit a PR by the end of the week.
I have been taking a look at json-schema and liform-react. I know it is possible to specify a format for a field. The current implementation of liform-react utilises the type property of every schema-property to determine the widget to make use of. However the use the format property together with the type property will make the choosing of appropriate widget more effective. For example,
from the above schema, we can see that using the type property of content, path and mode will give us an appropriate widget, however what if we did have a textarea widget and we made us of the format property of content to choose the widget. That'd more efficient. My proposal is that we check for the format property and return if a valid widget is found for it, else we fallback to using the type property. This double checking will help increase our widget choice efficiency.