CodeIgniter Forums
Standart for form_input and etc - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forum-31.html)
+--- Thread: Standart for form_input and etc (/thread-74990.html)



Standart for form_input and etc - XTAZ - 12-04-2019

Hello!

In my opinion, we must have standart for form_input. I want add class form-control to all inputs, I write this code:
PHP Code:
$defaults = [
    
'type'  => $type,
    
'name'  => is_array($data) ? '' $data,
    
'value' => $value,
    
'class' => $data['class'] ?? '',
];
        
if (isset(
$data['class'])) unset($data['class']);
$defaults['class'] .= ' form-control'
If I include more modules in CI4, this design will stop wotking, because all developers uses form_input in his own way.

Now I must write conditions, find class in $data, $extra, if finded $extra, I must write crutch for replace class=" to class="form-control, some will use ', some ",  then somethings more will stop working...