form_input仅作为CodeIgniter中的数字

I'd like to change the type of input field from text to numbers only.I've tried as following

<?= form_input('num', '','class="form-control" id="num", type="number"');?>

but not working

Try this one for numeric input:

$data = array(
  'name' => 'num',
  'id'   => 'num',
  'class'=> 'form-control',
  'type' => 'number'
);

echo form_input($data);

You should pass everything as an associative array, here the array index are attribute of HTML input tag.

<?= form_input(array(
  'name' => 'num',
  'class' => 'form-control',
  'type' => 'number'// input type number
));
?>

more info: http://www.codeigniter.com/userguide2/helpers/form_helper.html

$data = array(
  'name' => 'num',
  'id' => 'num',
  'class' => 'form-control',
  'type' => 'number'      //it's 'number', not 'numeric'
);

echo form_input($data);

I find it useful to add a step parameter for currency fields.

echo form_input(array(
    'name' => 'estimated_cost',
    'id' => 'estimated_cost',
    'class' => 'form-control',
    'type' => 'number',
    'step' => 0.01
));