Question

<?php
    $data = array(
        'class' => "btn btn-primary btn-lg",
        'name' => 'report'
    );

    echo '<span class="glyphicon glyphicon-exclamation-sign"></span> ';
    echo form_submit($data, 'Report');

    $data = array(
        'class'=>"btn btn-primary btn-lg",
        'name' => "search"
    );

    echo anchor("",'<span class="glyphicon glyphicon-search"></span> Search',$data);

    echo form_close();
?>  

I want to include <span class="glyphicon glyphicon-exclamation-sign"></span> on the form_submit. This span class is an image, I cant find a way to put it inside the button. http://puu.sh/6UbE8.jpg

The second one "echo anchor", its second parameter has a span class which is also an image followed by a word "Search". This is exactly what I want the previous "form_submit" to be looks like. http://puu.sh/6UbFt.png

Was it helpful?

Solution

Use form_button instead of form_submit, and wrap your span around label.

$data = array(
        'class' => "btn btn-primary btn-lg",
        'name' => 'report'
        );
echo form_button($data, '<span class="glyphicon glyphicon-exclamation-sign">Report</span>');

hope it will help

OTHER TIPS

$data = array(
    'name' => 'report',
    'id' => 'report',
    'value' => 'true',
    'type' => 'submit',
    'class' => 'btn btn-primary btn-lg'
);

echo form_button($data);

you can check http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top