1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage Form
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 JFormHelper::loadFieldClass('text');
13
14 /**
15 * Form Field class for the Joomla Platform.
16 * Supports a text field telephone numbers.
17 *
18 * @link http://www.w3.org/TR/html-markup/input.tel.html
19 * @see JFormRuleTel for telephone number validation
20 * @see JHtmlTel for rendering of telephone numbers
21 * @since 11.1
22 */
23 class JFormFieldTel extends JFormFieldText
24 {
25 /**
26 * The form field type.
27 *
28 * @var string
29 * @since 11.1
30 */
31 protected $type = 'Tel';
32
33 /**
34 * Name of the layout being used to render the field
35 *
36 * @var string
37 * @since 3.7.0
38 */
39 protected $layout = 'joomla.form.field.tel';
40
41 /**
42 * Method to get the field input markup.
43 *
44 * @return string The field input markup.
45 *
46 * @since 3.2
47 */
48 protected function getInput()
49 {
50 // Trim the trailing line in the layout file
51 return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
52 }
53
54 /**
55 * Method to get the data to be passed to the layout for rendering.
56 *
57 * @return array
58 *
59 * @since 3.7.0
60 */
61 protected function getLayoutData()
62 {
63 $data = parent::getLayoutData();
64
65 // Initialize some field attributes.
66 $maxLength = !empty($this->maxLength) ? ' maxlength="' . $this->maxLength . '"' : '';
67
68 $extraData = array(
69 'maxLength' => $maxLength,
70 );
71
72 return array_merge($data, $extraData);
73 }
74 }
75