Comments (15)
@stefan-korn yeah this is a good point. Hmm. Since this field is used for URLs 128 does seem very stingy. What do we think of
- Setting the maxlength by default to be 512, which seems likely to accommodate most URLs someone would be using here. Alternatively, is there a way to explicitly set no maxlength, like set it to zero or null? I can't find any reference to this in the docs.
- Having handleStringElement look for a maxlength property in the schema and apply that instead if present.
I don't know that I think we should make this settable in the UI schema. UI schema is supposed to extend what can be inferred from the schema itself, not prevent input that would otherwise be allowed by the schema, or override limits that are present in the schema. We generally try to follow the model of react-jsonschema-form and they do not allow setting maxlength via ui schema.
from dkan.
cc @paul-m who I think has been active in the Drupal core issues about this
from dkan.
@dafeder : You surely know, but if you set schema property "format" to "uri" for a string field, the maxlength will increase to 255. That is because the JSON Form widget uses a drupal "url" form element then (same for pattern property which translates to email form element).
So urls are not direcly related to this issue, only plain text fields. But if you want to extend it even to 512 then "uri" has to be tackled too.
from dkan.
Actually missed that, thanks for the clarification. 256 is probably still plenty for 99% of use cases, maybe let's just start with that as the default for all textfields?
from dkan.
How about PR #4168. This would increase the limit just for "textfield" elements provided by JSON Form widget.
from dkan.
maybe leave a hint or ToDo pointing to https://www.drupal.org/project/drupal/issues/3331028 in the code comments?
from dkan.
@dafeder : While fixing the tests in #4168 I came across ArrayHelper. There is buildSimpleArrayElement which builds a texfield without maxlength too. Not sure if maxlength should be set there too?
from dkan.
@dafeder : I changed the place of injecting maxlength from StringHelper to WidgetRouter. Injecting in StringHelper is problematic, because the WidgetRouter might change the type "textfield" to something else, i. e. Date Time widget and there the maxlength is causing trouble. Therefore injecting maxlength only after the WidgetRouter has done its changes and the type is still textfield.
from dkan.
Hm, this is way more complex than I have thought. ArrayHelper and ObjectHelper together with the "add one" button do their own thing in some way.
I'm now tending to solve it for our project on a general base with hook_element_info_alter for all textfields regardless whether they are from JSON Form Widget or anywhere else.
from dkan.
Hmm that is unfortunate... I will have to take a closer look at what's happening. I'd be open to bringing this in if it addresses the problem in most places and has test coverage and documents remaining open issues. But maybe needs a higher-level refactor to properly fix?
from dkan.
Yes, maybe some refactoring would help to solve it in the JSON Form Widget. Probably it will have to happen in the StringHelper, but then in the WidgetRouter one would need to remove the maxlength for those widgets that are changing the type again. I tried to avoid this, because this is kind of a trap when implementing new widgets for example. But since the fields without a widget do not touch the WidgetRouter, it cannot be solved directly in the WidgetRouter.
And above mentioned buildSimpleArrayElement should probably also go to StringHelper and not directly provide the textfield type.
But surely it is questionable if it is worth the effort, when core maybe changes this later on.
But from JSON Form Widget point of view, there would be no maxlength necessary at all, since everything is stored in the JSON field. So maybe the other way round, just kicking maxlength out (as you have mentioned above and I have not noticed until now) might be a better approach. Still this is also not straightforward I am afraid.
from dkan.
Related Issues (20)
- DKAN DDev Addon documentation link broken/missing HOT 1
- DKAN on headless VM HOT 2
- WidgetRouter accepts only PHP UUID HOT 5
- Number widget HOT 4
- Code documentation little messed up in WidgetRouter.php
- Set the default theme to Stark instead of Olivero when generating new site using DDEV for correct styling.
- Catch Guzzle Exception to avoid breaking harvest HOT 4
- Metastore service needs to call logger.factory HOT 1
- Use drupal-composer/info-rewrite for showing DKAN version in Drupal backend HOT 6
- Expose dataset properties as pseudo/extra fields HOT 8
- DKAN JS Frontend module - ReadMe Section Tips HOT 1
- Provide text_format render element for string schema properties HOT 1
- View DKAN Metastore (Datasets) should only list nodes of type Data
- Make harvester more defensive against bad data HOT 3
- Deprecated: Creation of dynamic property :$has_json_form_widget HOT 2
- Error : Call to a member function out() on boolean in leaflet_widget_widget_validate() (line 230 HOT 1
- Notice : Undefined index: label_visibility in field_group_table_field_group_pre_render() (line 181) HOT 2
- Allow to activate trailing delimiter for CSV parser HOT 1
- Dataset ComplexDataFacade returning wrong empty value HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dkan.