Placing a Bootstrap class inside a form generated with Codeigniter

Asked

Viewed 172 times

0

Can anyone tell me what I call the Bootstrap classes within a form I generated using Codeigniter? From what I’ve researched it uses an associative array, but I’m not getting it. For example, in the label I want to put class='sr-only' and in the input class="form-control input-lg".

echo form_open('crud/create');
echo validation_errors('<p>','</p>');
            echo form_label('Nome Completo');
            echo form_input(array('name'=>'nome'), '','autofocus');
            echo form_label('Email');
            echo form_input(array('name'=>'email'));
            echo form_label('Login');
            echo form_input(array('name'=>'login'));
            echo form_label('Senha');
            echo form_input(array('name'=>'senha'));
            echo form_label('Repita a senha');
            echo form_input(array('name'=>'senha2'));
            echo form_submit(array('name'=>'cadastrar');
echo form_close();
  • Tried to put inside array? echo form_input(array('name'=>'email', 'class' => 'nomedaclass'));

  • No input gives, but I’m getting a little complicated is on the label.

  • I solved it. I was able to use the associative array on the label.

2 answers

1

I managed to solve.

echo form_label('Nome Completo','',array('class'=>'sr-only'));

1


According to the CI documentation you should create an array with the attributes you want to add as follows:

$atributos = array (
'class' => 'sua class',
'style' => 'color: #fff;' );
// E assim por diante

And then add the variable attributes within your form_label that is to say

echo form_label('Nome Completo', $atributos);

you can see more details on documentation of the IC

  • Exactly, Rafael, was that I realized when consulting the documentation.

  • Use this way I passed you so the code is more organized @Fernandaferreira avoid using the other method of placing an array inside the form_label besides weird it gets ugly! rs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.