2013-11-22 26 views
2

所以我使用CodeIgniter表單助手創建了一個表單。我試圖給一些表單元素一個類,但是會發生一些奇怪的事情。我不喜歡這樣寫道:CodeIgniter,表單助手 - 向元素添加類

echo form_input('title', $this->input->post('title'), 'class="titleInput"'); 

當我檢查的元素,它實際上顯示了類有:

enter image description here

但它不會採取任何在CSS文件中給出的屬性的的。此外,當我做喜歡的事,醜陋:

echo form_input('title', $this->input->post('title'), style="height=30px"); 

當我檢查元素我得到這個:

enter image description here

但它實際上並沒有做給定的造型什麼。

希望有人能在這裏給我一隻手!

回答

5
$data = array(
      'name'  => 'title', 
      'value'   => $this->input->post('title'), 
      'class'  => 'titleInput', 
      'style'  => 'height:30px' 
     ); 

echo form_input($data); 

reference

+0

THX!我也閱讀過文檔,但是認爲我的方法也會起作用,因爲我在檢查元素時看到了類和樣式。在附註中,你應該編輯並在'value'後面添加一個逗號,並且刪除'style'後面的一個:) Thx for your help mate! – Kevinvhengst

+0

完成謝謝你 – Bhadra

+1

你會如何在上面添加'disabled'?沒有標識符,只是「禁用」 – user3264461