| 1 |
<?php |
| 2 |
defined('ABSPATH') || die(); |
| 3 |
|
| 4 |
class HashFormFieldEmail extends HashFormFieldType { |
| 5 |
|
| 6 |
protected $type = 'email'; |
| 7 |
|
| 8 |
protected function field_settings_for_type() { |
| 9 |
return array( |
| 10 |
'advanced_validation' => true, |
| 11 |
'clear_on_focus' => true, |
| 12 |
'invalid' => true, |
| 13 |
); |
| 14 |
} |
| 15 |
|
| 16 |
public function validate($args) { |
| 17 |
$errors = isset($args['errors']) ? $args['errors'] : array(); |
| 18 |
if ($args['value'] != '' && !is_email($args['value'])) { |
| 19 |
$errors['field' . $args['id']] = apply_filters('hashform_translate_string', HashFormFields::get_error_msg($this->field, 'invalid'), 'Hash Form', HashFormBuilder::get_form_title($args['form_id']) . ' - ' . $args['id'] . ' - ' . 'Field Validation Message'); |
| 20 |
} |
| 21 |
return $errors; |
| 22 |
} |
| 23 |
|
| 24 |
public function sanitize_value(&$value) { |
| 25 |
return HashFormHelper::sanitize_value('sanitize_email', $value); |
| 26 |
} |
| 27 |
|
| 28 |
public function input_html() { |
| 29 |
?> |
| 30 |
<input type="email" <?php $this->field_attrs(); ?> /> |
| 31 |
<?php |
| 32 |
} |
| 33 |
|
| 34 |
} |
| 35 |
|