CodeIgniter Forums

Full Version: Standart for form_input and etc
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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...