Example #1
0
 private static function make_input($type, $name = NULL, $inner = NULL, $value = NULL, $placeholder = NULL)
 {
     // This needs a tad bit of work. Simply builds an input HTML tag by the use of constructing an assoc. array
     // Could make use of array functions instead of foreach loops
     $name = trim($name);
     // html field types that do not take 'value' statements ...
     switch (trim($type)) {
         default:
             $ab_types = array('select', 'radio', 'number', 'range', 'checkbox', 'password', 'textarea');
             $a_names = array('type', 'name', 'inner', 'value', 'placeholder');
             // this needs some work..
             foreach (func_get_args() as $loc => $value) {
                 $value != NULL && $loc != 2 && $value != '' and $a[trim($a_names[$loc])] = trim($value);
             }
             !in_array($name, $ab_types) and isset($_POST[$name]) && $_POST[$name] != '' and $a['value'] = $_POST[$name];
             $type != 'checkbox' && !isset($a['value']) && strpos($inner, 'value') === 0 and $a['value'] = $inner;
             if (isset($a['value'])) {
                 if ($a['value'] == $inner) {
                     unset($inner);
                 }
             }
             foreach (array_filter($a) as $key => $value) {
                 $a[$key] = " {$key}='{$value}'";
             }
             return noClass_html::input(NULL, (isset($a) && is_array($a) ? implode($a, '') : '') . ($inner != NULL ? $inner : NULL));
             break;
         case 'html':
             return $value;
             break;
         case 'submit':
             return noClass_html::input__sumbit($name);
             break;
         case 'textarea':
             return noClass_html::textarea(isset($_POST[$name]) ? $_POST[$name] : '', 'name="' . $name . '"' . ($inner ? $inner : ''));
             break;
     }
 }