public function html_element()
{
// Import base data
$data = $this->data;
$input = '';
foreach ($this->parts as $type => $val) {
isset($data['value']) or $data['value'] = '';
$temp = $data;
$temp['name'] = $this->data['name'] . '[' . $type . ']';
$offset = strlen($data['value']) == 10 ? 0 : 3;
switch ($type) {
case 'area_code':
if (strlen($data['value']) == 10) {
$temp['value'] = substr($data['value'], 0, 3);
} else {
$temp['value'] = '';
}
$temp['class'] = 'area_code';
$input .= form::input(array_merge(array('value' => $val), $temp)) . '-';
break;
case 'exchange':
$temp['value'] = substr($data['value'], 3 - $offset, 3);
$temp['class'] = 'exchange';
$input .= form::input(array_merge(array('value' => $val), $temp)) . '-';
break;
case 'last_four':
$temp['value'] = substr($data['value'], 6 - $offset, 4);
$temp['class'] = 'last_four';
$input .= form::input(array_merge(array('value' => $val), $temp));
break;
}
}
return $input;
}