Define a textfield in XML that includes inputmode
<field name="amount" type="text" default="" label="Amount" description="Amount" hint="Amount" class="form-control" inputmode="numeric" />
<input type="text" name="jform[amount]" id="jform_amount" value="" class="form-control" placeholder="Amount" autocomplete="off" inputmode="numeric" />
<input type="text" name="jform[amount]" id="jform_amount" value="" class="form-control" placeholder="Amount" autocomplete="off" inputmode=" inputmode="numeric"" />
Joomla! 3.8.4
PHP 7.1.13
Apache/Linux
In order for this to work as expected for my component, I have overridden for now JFormFieldText to change Line 266 from:
$inputmode = !empty($this->inputmode) ? ' inputmode="' . $this->inputmode . '"' : '';
to:
$inputmode = !empty($this->inputmode) ? $this->inputmode : '';
I have not yet looked at other field types for how they handle inputmode
Labels |
Added:
?
|
Status | New | ⇒ | Discussion |
Category | ⇒ | Code style Fields |
As above, this is the XML:
<field name="amount"
type="text"
default=""
label="Amount"
description="Amount"
hint="Amount"
class="form-control"
inputmode="numeric"
/>
And if I had it incorrect in the XML, the override would make no difference.
Upon digging further, inputmode attribute HTML is set in JFormFieldText::getLayoutData() (Line 266)
$inputmode = !empty($this->inputmode) ? ' inputmode="' . $this->inputmode . '"' : '';
AND in the text field layout file "layouts\joomla\form\field\text.php" (Line 74)
!empty($inputmode) ? 'inputmode="' . $inputmode . '"' : '',
It seems to me that it should be defined in one place or the other, not both.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-02-10 02:10:39 |
Closed_By | ⇒ | Quy |
Closed_By | Quy | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/19563
See PR #19632
Just at a glance, it looks like you're doing it wrong in the XML. Your XML field element should just do
inputmode="numeric"
, it seems like you've gotinputmode=" inputmode="numeric""
in your definition.