mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
parent
4af6039107
commit
422ceaff85
2 changed files with 24 additions and 18 deletions
|
@ -1826,12 +1826,12 @@ class FormHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Form->input('Contact.email', array('id' => 'custom'));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
'div' => array('class' => 'input email'),
|
||||
'label' => array('for' => 'custom'),
|
||||
'Email',
|
||||
'/label',
|
||||
array('input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][email]',
|
||||
'type' => 'email', 'name' => 'data[Contact][email]',
|
||||
'id' => 'custom', 'maxlength' => 255
|
||||
)),
|
||||
'/div'
|
||||
|
@ -1845,7 +1845,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
'Email',
|
||||
'/label',
|
||||
array('input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][email]',
|
||||
'type' => 'email', 'name' => 'data[Contact][email]',
|
||||
'id' => 'ContactEmail', 'maxlength' => 255
|
||||
)),
|
||||
'/div'
|
||||
|
@ -1920,12 +1920,12 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->Form->request->data = array('Contact' => array('phone' => 'Hello & World > weird chars'));
|
||||
$result = $this->Form->input('Contact.phone');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
'div' => array('class' => 'input tel'),
|
||||
'label' => array('for' => 'ContactPhone'),
|
||||
'Phone',
|
||||
'/label',
|
||||
array('input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][phone]',
|
||||
'type' => 'tel', 'name' => 'data[Contact][phone]',
|
||||
'value' => 'Hello & World > weird chars',
|
||||
'id' => 'ContactPhone', 'maxlength' => 255
|
||||
)),
|
||||
|
@ -2808,9 +2808,9 @@ class FormHelperTest extends CakeTestCase {
|
|||
'input' => array('type' => 'hidden', 'name' => 'data[Contact][id]', 'id' => 'ContactId'),
|
||||
array('div' => array('class' => 'input text')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input email')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input tel')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input password')),
|
||||
'*/div',
|
||||
|
@ -2833,9 +2833,9 @@ class FormHelperTest extends CakeTestCase {
|
|||
'input' => array('type' => 'hidden', 'name' => 'data[Contact][id]', 'id' => 'ContactId'),
|
||||
array('div' => array('class' => 'input text')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input email')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input tel')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input password')),
|
||||
'*/div',
|
||||
|
@ -2863,9 +2863,9 @@ class FormHelperTest extends CakeTestCase {
|
|||
'input' => array('type' => 'hidden', 'name' => 'data[Contact][id]', 'id' => 'ContactId'),
|
||||
array('div' => array('class' => 'input text')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input email')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input tel')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input password')),
|
||||
'*/div',
|
||||
|
@ -2889,9 +2889,9 @@ class FormHelperTest extends CakeTestCase {
|
|||
'input' => array('type' => 'hidden', 'name' => 'data[Contact][id]', 'id' => 'ContactId'),
|
||||
array('div' => array('class' => 'input text')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input email')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input tel')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input password')),
|
||||
'*/div',
|
||||
|
@ -2922,9 +2922,9 @@ class FormHelperTest extends CakeTestCase {
|
|||
'input' => array('type' => 'hidden', 'name' => 'data[Contact][id]', 'id' => 'ContactId'),
|
||||
array('div' => array('class' => 'input text')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input email')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input tel')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input password')),
|
||||
'*/div',
|
||||
|
@ -2952,9 +2952,9 @@ class FormHelperTest extends CakeTestCase {
|
|||
'input' => array('type' => 'hidden', 'name' => 'data[Contact][id]', 'id' => 'ContactId'),
|
||||
array('div' => array('class' => 'input text')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input email')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input text')),
|
||||
array('div' => array('class' => 'input tel')),
|
||||
'*/div',
|
||||
array('div' => array('class' => 'input password')),
|
||||
'*/div',
|
||||
|
|
|
@ -1129,6 +1129,10 @@ class FormHelper extends AppHelper {
|
|||
$options['type'] = 'select';
|
||||
} elseif (in_array($fieldKey, array('psword', 'passwd', 'password'))) {
|
||||
$options['type'] = 'password';
|
||||
} elseif (in_array($fieldKey, array('tel', 'telephone', 'phone'))) {
|
||||
$options['type'] = 'tel';
|
||||
} elseif ($fieldKey === 'email') {
|
||||
$options['type'] = 'email';
|
||||
} elseif (isset($options['checked'])) {
|
||||
$options['type'] = 'checkbox';
|
||||
} elseif ($fieldDef = $this->_introspectModel($modelKey, 'fields', $fieldKey)) {
|
||||
|
@ -1235,7 +1239,9 @@ class FormHelper extends AppHelper {
|
|||
is_scalar($fieldDef['length']) &&
|
||||
$options['type'] !== 'select'
|
||||
);
|
||||
if ($autoLength && $options['type'] == 'text') {
|
||||
if ($autoLength &&
|
||||
in_array($options['type'], array('text', 'email', 'tel', 'url'))
|
||||
) {
|
||||
$options['maxlength'] = $fieldDef['length'];
|
||||
}
|
||||
if ($autoLength && $fieldDef['type'] == 'float') {
|
||||
|
|
Loading…
Reference in a new issue