Closed skworden closed 9 years ago
Doc => activeInput
Thanks! I didn't see that. Well my real issue was trying to use masked input. Can we have it use activeInput instead of activeTextInput?
the plugin by default supports type text and type tel but by using ActiveTextInput we lose the functionality of tel for mobile devices.
in the jquery.inputmask.bundle.js from
var isSupported = "text" == inputType || "tel" == inputType;
For the time being i just created a class in my common/widgets/ called MaskedInputType to use the changes above; however, it would be nice if it went into the core.
put this in my common ->widgets
<?php
namespace common\widgets;
use yii\widgets\MaskedInput;
use yii\helpers\Html;
class MaskedInputType extends MaskedInput {
/**
* @param string $type the input type ('text', 'tel','ur'l) defaults to 'text'
* tel brings up number pad/ i use it for phone, zip, etc anything that only uses numbers
* by using tel it will prompt the number pad when user clicks the field on mobile devices.
*/
public $type = 'text';
public function run()
{
if ($this->hasModel())
{
echo Html::activeInput($this->type, $this->model, $this->attribute, $this->options);
} else
{
echo Html::input($this->type, $this->name, $this->value, $this->options);
}
$this->registerClientScript();
}
}
then i just call it like
<?
use common\widgets\MaskedInputType;
echo $form->field($applicant, 'phone')->widget(MaskedInputType::classname(), [
'type' => 'tel',
'mask' => '(999) 999-9999',
'options' => ['class' => 'form-control'],
]);
?>
if anyone wants to use it.
here are what the different types are and what they do
http://blog.teamtreehouse.com/using-html5-input-types-to-enhance-the-mobile-browsing-experience
See below post