- Issue created by @ldavidsp
- Status changed to Needs work
over 1 year ago 2:37pm 10 July 2023 - heddn Nicaragua
-
+++ b/src/Plugin/Field/FieldWidget/PhoneNumberWidget.php @@ -61,6 +61,7 @@ class PhoneNumberWidget extends WidgetBase { + 'size' => NULL,
default to 60
'size' => 60,
-
+++ b/src/Plugin/Field/FieldWidget/PhoneNumberWidget.php @@ -94,6 +95,14 @@ class PhoneNumberWidget extends WidgetBase { + '#default_value' => $this->getSetting('size') !== NULL ? $this->getSetting('size') : 60,
Then this can just be:
'#default_value' => $this->getSetting('size'),
-
+++ b/src/Element/PhoneNumber.php @@ -172,6 +172,7 @@ class PhoneNumber extends FormElement { + 'size' => $settings['size'] ?? 60,
A default size should be set in
defaultSettings()
and we need an entry in config schema for the setting. -
+++ b/src/Plugin/Field/FieldWidget/PhoneNumberWidget.php @@ -139,6 +150,7 @@ class PhoneNumberWidget extends WidgetBase { + 'size' => isset($settings['size']) ? $settings['size'] : NULL,
'size' => $settings['size'],
Some minor feedback. But generally this looks like a great idea.
-
- Status changed to Needs review
over 1 year ago 4:21pm 10 July 2023 - heddn Nicaragua
+++ b/src/Element/PhoneNumber.php @@ -172,6 +172,7 @@ class PhoneNumber extends FormElement { + 'size' => $settings['size'],
Oh, this is the render element, we need an isset like the line before.
- heddn Nicaragua
This responds to the feedback. And doesn't limit the render element to only sizing the phone number but also makes it possible to alter the size of the phone extension as well. The change is only to the API of the render element. I don't think changing the size of the extension is all that needed, so I didn't make it a configuration option on the field widget.
- 🇮🇳India kapil-virasat
I have reproduce the issue on my local , and I have added changes for fix the issue by adding some changes in phone number field for set size.
- heddn Nicaragua
I'm not sure where #10 came from. There's no interdiff and it looks like a reposting of an earlier patch. Hiding it so it is clear that #9 is the preferred direction here.
- 🇺🇸United States volkswagenchick San Francisco Bay Area
@kapil-virasat
As @heddn mentioned, your patch does look like a reposting of an earlier patch.
I find it helpful to create an interdiff to be sure that I made the necessary changes and the changes are reflected in the patch. In the past, I have inadvertently shared the original patch or an empty patch, but with an interdiff I can quickly scan the file and confirm that the changes were made.
This also helps those who review your work.
Here is some documentation around what is an interdiff → , why we create them, and how others find them useful when reviewing patches.
Thanks,
AmyJune HIneline, Drupal Core Mentor
- Status changed to Needs work
over 1 year ago 8:59am 17 July 2023 - 🇧🇪Belgium tim-diels Belgium 🇧🇪
Thanks for the issue and all the work already. I'm willing to add this if the patch can be completed. I'm missing some more parts like:
- config schema for the extension_size
- maybe also expose the extension_size as field on the form?
- properties documentation in PhoneNumber for development usage
For the rest is seems ok. Did not test it yet, but will test once these extras are addressed.
- Status changed to Needs review
over 1 year ago 3:20pm 17 July 2023 - heddn Nicaragua
I intentionally didn't add the phone extension to the widget. The chance that someone needs to ever modify the extension is pretty low. However, if we are going to modify the render element's API, it seemed like a pretty easy addition while we are messing with things. If someone _does_ need to ever change the widget, they can do so pretty easily in a custom widget. That should cover bullets 1 & 2 in #14.
Last bullet addressed here.
- 🇧🇪Belgium tim-diels Belgium 🇧🇪
Interdiff was same as previous interdiff. So just for easier review, i've uploaded the correct interdiff.
- last update
over 1 year ago CI aborted - 🇧🇪Belgium tim-diels Belgium 🇧🇪
For my bullet point for the config schema, this was still a valid point to be taken care of as it gave me an error on the extension_size key for config.
After testings, it seems the part where you add the defaults in valueCallback is not needed.
This seems not to be the place to set defaults.I adjusted the patch and tested this with both a field added through UI and on a custom form. But would like some feedback if this works for you too.
Example custom form:
$form['phone_number'] = [ '#type' => 'phone_number', '#title' => $this->t('Phone Number'), '#phone_number' => [ 'extension_field' => TRUE, 'phone_size' => 40, 'extension_size' => 10, ] ];
- heddn Nicaragua
Did we test without any defined phone or extension size? Does that work? If that works, then I think this is good to go.
- Status changed to RTBC
over 1 year ago 6:41am 21 July 2023 - last update
over 1 year ago Patch Failed to Apply - 🇧🇪Belgium tim-diels Belgium 🇧🇪
Yes, I tested with just adding the fields and no changes. I'm going to commit this, thanks for the help @heddn.
-
tim-diels →
committed 475c6469 on 2.0.x authored by
ldavidsp →
Issue #3373460 by ldavidsp, heddn, tim-diels: Phone Number field does...
-
tim-diels →
committed 475c6469 on 2.0.x authored by
ldavidsp →
- Status changed to Fixed
over 1 year ago 6:57am 21 July 2023 - Status changed to Fixed
over 1 year ago 1:54pm 21 July 2023