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

[Phone field] - extend the phoneFormat field or create a new one to return format properties along with the selected format #441

Open
Gytjarek opened this issue Jul 31, 2024 · 1 comment
Labels
status: confirmed 📍 The issue has been confirmed and reproduced. type: enhancement ⚡ Improves on an existing feature

Comments

@Gytjarek
Copy link

Gytjarek commented Jul 31, 2024

What problem does this address?

Phone field currently returns two formats: international and standard. By having this value, you don't get much except its name. It would be nice to expand that field or create another one to get the currently selected phone format with their values:

'standard' => array(
'label' => '(###) ###-####',
'mask' => '(999) 999-9999',
'regex' => '/^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$/',
'instruction' => '(###) ###-####',
'type' => 'standard',
),

So we know its properties, which would help in implementing it. In the same way, we could support more custom formats added with thegform_phone_formats filter

What is your proposed solution?

Create a new field for the Phone field which will be returning other props, like label, mask, regex and instruction along with selected type. Make sure, custom formats will be supported as well

What alternatives have you considered?

No response

Additional Context

No response

@justlevine justlevine added type: enhancement ⚡ Improves on an existing feature status: confirmed 📍 The issue has been confirmed and reproduced. labels Aug 2, 2024
@justlevine
Copy link
Member

Thanks for suggesting this @Gytjarek !

Normally, I'm not a fan of mixing implementation details with implementation definitions, but in this case, since gform_phone_formats exposes the entire object, we want to be able to provide the site-specific context.

Feel free to submit a PR if you want this in sooner than I can get around to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed 📍 The issue has been confirmed and reproduced. type: enhancement ⚡ Improves on an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants