Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WIP][Form] Add TelType #11360

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

Closed
wants to merge 11 commits into from
Closed

[WIP][Form] Add TelType #11360

wants to merge 11 commits into from

Conversation

lepiaf
Copy link
Contributor

@lepiaf lepiaf commented Jul 9, 2014

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #8026
License MIT
Doc PR symfony/symfony-docs#4040

'pattern' => '',
'maxlength' => 10,
'autofocus' => '',
'autocomplete' => 'on'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These options don't make sense. Most of them loo like you are tryign to configure HTML attributes (but not working because you don't render them), and Symfony already has a way to configure them through the attr option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setAllowedValues and setAllowedTypes are useless ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the options you configure here are useless as you never use them

@L0rD59
Copy link

L0rD59 commented Jul 9, 2014

Hi, thx for contributing,

What about internationalization ? Maybe a Tel Validator would be great too ?

@lepiaf
Copy link
Contributor Author

lepiaf commented Jul 9, 2014

Do you mean display phone number in specific format ?

Yes It's interesting, but I can't do in this PR. (could I?)

@thewilkybarkid
Copy link
Contributor

@L0rD59 Dealing with telephone numbers is hard. My bundle that does this uses a port of libphonenumber which knows a huge range of rules.

@fabpot
Copy link
Member

fabpot commented Jul 11, 2014

If there is a third party doing it well, I'm all in favor of it.

@javiereguiluz
Copy link
Member

Beware that including the proposed telephone validator would add 1,366 new files and 15 MB to the Symfony source code.

Don't get me wrong @thewilkybarkid. Your library is great and we really appreciate that you have developed a Symfony bundle. But in my opinion, a full telephone number validator is a very specific need.

@fabpot
Copy link
Member

fabpot commented Jul 11, 2014

I'm not talking about including this in Symfony, we can just rely on the external lib.

<input type="tel"
<?php echo $view['form']->block($form, 'widget_attributes') ?>
value="<?php echo $view->escape($value) ?>"
/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not <?php echo $view['form']->block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'tel')) ?> as for other widgets ?

@lepiaf
Copy link
Contributor Author

lepiaf commented Jul 13, 2014

The bundle from @thewilkybarkid is interesting.

@jeremy-derusse I didn't see it. I can change it.

@lepiaf
Copy link
Contributor Author

lepiaf commented Jul 20, 2014

does anyone has more idea for this feature ? or suggestion ?

@@ -192,6 +192,13 @@
{{- block('button_widget') -}}
{%- endblock reset_widget %}

{% block tel_widget %}
{% spaceless %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaceless were removed in a recent PR (#11386) can you apply changes to the tel_widget ?

* @return mixed The value in the transformed representation
*
* @throws TransformationFailedException When the transformation fails.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use {@inheritdoc} if your comment doe not improve the interface one

return '';
}

return PhoneNumberUtil::getInstance()->format($value, $this->region);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PhoneNumberUtil::format() expects an object, https://github.com/giggsey/libphonenumber-for-php/blob/master/src/libphonenumber/PhoneNumberUtil.php#L992

You should check if the $value is correct and throw an TransformationFailedException if its not.

@lepiaf
Copy link
Contributor Author

lepiaf commented Jul 20, 2014

Thanks for your feedback, I will improve it.

@@ -0,0 +1,54 @@
<?php

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing license header

@linaori
Copy link
Contributor

linaori commented Jul 31, 2014

https://github.com/misd-service-development/phone-number-bundle/

Already has a phone type for doctrine and a phone type for your form.

*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addViewTransformer(new PhoneNumberToStringTransformer($options['region']));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a view transformer but a model transformer. The parent type (text) expects the norm data to be string, so it should be respected in this type

@fabpot
Copy link
Member

fabpot commented Sep 15, 2014

Closing for the reasons explained by @stof, we cannot depend on this library internally. And as there is already a bundle providing such support, that's a better option.

@fabpot fabpot closed this Sep 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants