Exemplo n.º 1
0
 public static function input_html($field, $echo = true)
 {
     global $frm_vars;
     $frm_settings = FrmAppHelper::get_settings();
     $add_html = '';
     if (FrmField::is_option_true($field, 'read_only') && $field['type'] != 'hidden') {
         global $frm_vars;
         if (isset($frm_vars['readonly']) && $frm_vars['readonly'] == 'disabled' || current_user_can('frm_edit_entries') && FrmAppHelper::is_admin()) {
             //not read only
             //}else if($field['type'] == 'select'){
             //$add_html .= ' disabled="disabled" ';
         } else {
             if (in_array($field['type'], array('radio', 'checkbox'))) {
                 $add_html .= ' disabled="disabled" ';
             } else {
                 $add_html .= ' readonly="readonly" ';
             }
         }
     }
     if (FrmField::is_multiple_select($field)) {
         $add_html .= ' multiple="multiple" ';
     }
     if (FrmAppHelper::is_admin_page('formidable')) {
         if ($echo) {
             echo $add_html;
         }
         //don't continue if we are on the form builder page
         return $add_html;
     }
     if ($frm_settings->use_html) {
         if (FrmField::is_option_true($field, 'autocom') && ($field['type'] == 'select' || $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'select')) {
             //add label for autocomplete fields
             $add_html .= ' data-placeholder=" "';
         }
         if ($field['type'] == 'number' || $field['type'] == 'range') {
             if (!is_numeric($field['minnum'])) {
                 $field['minnum'] = 0;
             }
             if (!is_numeric($field['maxnum'])) {
                 $field['maxnum'] = 9999999;
             }
             if (!is_numeric($field['step'])) {
                 $field['step'] = 1;
             }
             $add_html .= ' min="' . esc_attr($field['minnum']) . '" max="' . esc_attr($field['maxnum']) . '" step="' . esc_attr($field['step']) . '"';
         } else {
             if (in_array($field['type'], array('url', 'email', 'image'))) {
                 if ((!isset($frm_vars['novalidate']) || !$frm_vars['novalidate']) && ($field['type'] != 'email' || isset($field['value']) && $field['default_value'] == $field['value'])) {
                     // add novalidate for drafts
                     $frm_vars['novalidate'] = true;
                 }
             }
         }
     }
     $add_html .= FrmProFieldsHelper::setup_input_masks($field);
     if ($echo) {
         echo $add_html;
     }
     return $add_html;
 }