<?php echo form_submit(['type'=>'submit', 'class'=>'btn login-btn', 'name'=>'btnLogin', 'i class'=>'icon-long-arrow-right' , 'value'=>'Login']); ?>
How to display an icon on button in Codeigniter.I tried this but it didn't show icon on button.Where to make change so that icon will displayed on button?
$data = array(
'name' => 'button',
'id' => 'button',
'value' => 'true',
'type' => 'submit',
'class'=>'btn btn-primary btn-sm icon-cancel-circle2',
'content' => '<i class="icon-long-arrow-right"></i>'
);
echo form_button($data);
you can use this.Hope it helps.
try this
<?php echo form_submit('btnLogin', 'Login', '"class"="btn login-btn" "i class"="icon-long-arrow-right"'); ?
the first parameter is the name, second is the value of your button.
Related
The code:
<?php echo $this->Form->submit('<i class="glyphicon glyphicon-arrow-right"></i>', array('class' => array('btn btn-danger')), array('escape' => false)); ?>
Instead of glyphicon it shows just text:
<i class="glyphicon glyphicon-arrow-right"></i>
How to solve this?
As per the docs, you can't use escape with Submit- you have to use Button instead and specify that it's a submit button:
echo $this->Form->button('<i class="glyphicon glyphicon-arrow-right"></i>', array(
'type' => 'submit',
'class' => 'btn btn-danger',
'escape' => false
));
Form->submit() should take two options, a caption and an array of options. You are passing it the caption plus two arrays. Also I don't think in this case you need to wrap these options within sub-arrays.
Try this:
echo $this->Form->submit('<i class="glyphicon glyphicon-arrow-right"></i>',
array('class' => 'btn btn-danger', 'escape' => false)
);
Html button is
<button class="btn" type="submit"><i class="icon-search"></i> Go</button>
I changed it into Yii as
<?php
echo CHtml::submitButton('Go', array('id' => 'btSubmit',
'class' => 'btn',
'name' => 'files'
));
?>
How can i add to button
This will work
echo CHtml::tag('button', array(
'name'=>'btnSubmit',
'type'=>'submit'
), '<i class="icon-search"></i> Go');
will generate
<button name="btnSubmit" type="submit"><i class="icon-search"></i> Go</button>
According to the yii source code the CHtml::tag method requires a third parameter to submit internal content. The CHtml::button method does not pass this through, so you can't add internal HTML.
Using the tag method directly should work however:
echo CHtml::tag('button',[
'id'=>'btsubmit','class'=>'btn','name'=>'files','type'=>'submit'
],'<i class="icon-search"></i> Go');
<?php echo CHtml::submitButton(
CHtml::tag('i', array('class' => 'icon-search')) . ' Go',
array('id' => 'btSubmit',
'class' => 'btn',
'name' => 'files')
);
?>
Use CHtml::tag('i', array('class' => 'icon-search')) . ' Go' instead of 'Go' in your code.
I want to pass a php variable to modal window , what i am doing is opening a modal window using this link , but i want to pass a variable to this link and get same variable in modal window , i try to to do this to append a text in some div but it return html that i am unable to get in query
echo CHtml::link(
'Set Recipe', '', array(
'class' => 'testclass',
'id' => $finalDate,
'data-toggle' => 'modal',
'data-target' => '#myModal',
'fahadVar' => $finalDate
));
and when i click this button i got modal window how to get variable set in button
Here is simple modal code of yiibooster
<div class="modal-body">
<p>One fine body...</p>
</div>
<div class="modal-footer">
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'type' => 'primary',
'label' => 'Save changes',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'label' => 'Close',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
</div>
<?php $this->endWidget(); ?>
thanks in advance
You should create a Widget.
Note: I copied below from another post. It works like charm.
First Create a new widget. Let say the name is CategoryWidget. Put this widget under components directory protected/components.
class CategoryWidget extends CWidget {
public function run() {
$models = Category::model()->findAll();
$this->render('category', array(
'models'=>$models
));
}
}
Then create a view for this widget. The file name is category.php. Put it under protected/components/views
category.php
<?php if($models != null): ?>
<ul>
<?php foreach($models as $model): ?>
<li><?php echo $model->name; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Then call this widget from your main layout.
main.php
// your code ...
<?php $this->widget('CategoryWidget') ?>
<?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
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
$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
I have a simple delete function. Here is where I set the custom data:
<?php echo $this->Html->link(
__('Delete'),
'#CoursesModal',
array(
'class' => 'btn-remove-modal',
'data-toggle' => 'modal',
'role' => 'button',
'data-uid' => $course['Course']['id'],
'data-uname' => $course['Course']['name']
));
?>
It shows in the element fine:
Delete
But when it comes to deleting this object (here's the code for it:)
<?php echo $this->Html->link(__('Delete'),'/courses/delete/#{uid}',array('class' => 'btn btn-danger delete-course-link')) ?>
For some reason the {uid} doesn't translate to 5 - which causes it not to work.
What am I doing wrong?