-
Notifications
You must be signed in to change notification settings - Fork 171
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
#4068: Provide number widget #4069
Conversation
@stefan-korn this would need test coverage before it can be merged. |
@stefan-korn are you able to add some coverage? The easiest thing would probably be to add a number field to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will satisfy codeclimate about code/doc standards
* @param mixed $spec | ||
* Object with spec for UI options. | ||
* optional specs | ||
* - step | ||
* - min | ||
* - max |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param mixed $spec | |
* Object with spec for UI options. | |
* optional specs | |
* - step | |
* - min | |
* - max | |
* @param object $spec | |
* Specification for UI options. Optional properties: | |
* - step: Ensures that the number is an even multiple of step. | |
* - min: Minimum value. | |
* - max: Maximum value. |
* @return array | ||
* The element configured as number. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return array | |
* The element configured as number. | |
*/ | |
* @return array | |
* The element configured as number. | |
* | |
* @see \Drupal\Core\Render\Element\Number | |
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefan-korn have given this another review. See my one comment here, I was able to cause an error by giving the ui schema a step but not a max.
I'd like to get this in, but I think it needs a little more work. Beyond the comments in this and previous reviews, I think it should also work to define a field as "number" directly in the schema, with no additional definition in the UI schema. This may mean adding a new "helper" class, or else consolidating "number" and "integer" since they ultimately use the same field type.
if (isset($spec->min)) { | ||
$element['#min'] = $spec->min; | ||
} | ||
if (isset($spec->step)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stefan-korn shouldn't this be $spec->max
?
@dafeder : I addressed your comments. Regarding "number" in the schema. I wasn't aware that there is the integer field. It is only used once in the data-dictionary.json I suppose and we do not need data dictionary right now, so I missed that. Should the schema be configurable about step, min and max? That way no widget "number" would be needed at all? |
@stefan-korn re-thinking this I think the "number" field in the schema itself can be dealt with separately, should not be a blocker for this. I did a new PR from this that hits the test coverage, closing this in favor of #4215. Thanks! |
fixes #4068
QA Steps