I have a link that has a button class.
I need to place an icon in the button, so the span tag is needed to do that, but I can't give span the class. I tried like this
<span class="glyphicon glyphicon-search"></span>
This is my link
<?php echo $this->Html->link(
$this->Html->tag('span',__('Crear Pacientes',true)),
array('controller' => 'pacientes', 'action' => 'add'),
array('escape' => false, 'class' => 'btn btn-info')
);
?>
How can I add the class to the span tag?
You can use 'escape'=>false option
<?php
echo $this->Html->link(
'<span class="glyphicon glyphicon-search"></span>',
array(
'controller'=>'pacientes',
'action'=>'add'
),
array(
'escape'=>false,
'class'=>'btn btn-info'
'escape'=>false //NOTICE THIS LINE ***************
)
);
?>
see Explanation Here
or, add array('class' => 'glyphicon glyphicon-search')
<?php
echo $this->Html->link(
$this->Html->tag(
'span',
__('Crear Pacientes',true),
array('class' => 'glyphicon glyphicon-search') //NOTICE THIS LINE ***************
),
array(
'controller'=>'pacientes',
'action'=>'add'
),
array(
'escape'=>false,
'class'=>'btn btn-info'
)
);
?>
Related
I was trying to pass the last inserted id through form action in Cakephp when i click on a button.
I am a newbie in Cakephp. Here is the code i found out. Can you suggest the correct method tho get the last inserted is through Form?
<?php echo $this->Html->link('View Quote', array('controller' => 'Stockcheck', 'action' => '../Quote/QuoteNo=Q1-1'), array('class' => 'button')); ?>
QuoteNo=Q1-1 should be my last inserted id and QuoteNo is my field
Try this code :
echo $this->Html->link('View Quote', array('controller' => 'Stockcheck', 'action' => '../Quote/', $your_id));
for more help please read this link
<?= $this->Form->postLink('<i class="fa fa-trash-o"></i><span class="hidden-xs"> ' . __('Delete') . '</span>', ['_name' => 'delete-administrator', $administrator->id], ['confirm' => "Are you sure you want to delete {$administrator->full_name}?", 'class' => 'btn btn-sm red', 'escape' => false, 'title' => 'Delete administrator details']); ?>
<?= $this->Form->postLink('<i class="fa fa-trash-o"></i><span class="hidden-xs"> ' . __('Delete') . '</span>', ['_name' => 'edit-administrator', $administrator->id], ['class' => 'btn btn-sm red', 'escape' => false, 'title' => 'Edit administrator details']); ?>
- Using route name
This code in pic below:
Image:
Actually it deppends on form_submit($data);. But you can make data like this, so you can insert the $data['html'] inside the botton.
$data = array(
'class' => 'btn btn-primary btn-lg btn-myblock',
'name' => 'signin',
'value' => 'Sign In',
'html'=>'<span class="glyphicon glyphicon-user"></span>'
);
?>
<?php echo form_submit($data); ?>
I'd like to add a icon <i> tag to a Cakephp link.
Here is my code :
<?= $this->Html->link($this->Html->tag('i', '', array('class' => 'fa fa-shopping-cart')).'Cart', array('controller' => 'shop', 'action' => 'cart')) ?>
This line generates :
<i class="fa fa-shopping-cart"></i>Cart
Why < is replaced by its hexa value? My charset is UTF-8.
Thanks!
Add option 'escape' set to false:
<?= $this->Html->link($this->Html->tag('i', '', array('class' => 'fa fa-shopping-cart')).'Cart', array('controller' => 'shop', 'action' => 'cart'), array('escape' => false)) ?>
Documentation page about HtmlHelper.
Html->link($this->Html->tag('i', '',['class' => 'fa fa-shopping-cart']).'Cart',['controller' => 'shop', 'action' => 'cart'], ['escape' => false]); ?>
[below translated from translate.google.com]
I'm looking for the syntax of how to make a button disabled in CakePHP and I can not get a result; My application need to first save a field for a button to finish the whole process after another button. The first button is a submit and redirects to the same page. The second button performs a function of the controller and go to the next process. I want to prevent the user to go to the next procedure without saving the first; I already have a variable that defines whether it is safe or not, just do not know how to make the Finish button is disabled;
Button code:
echo $this->Html->link(
$this->Html->tag('span', '', array('class' => 'glyphicon glyphicon-ok')) . " Finalizar",
array('controller' => 'Questoes','action' => 'limparSession'),
array('role' => 'button', 'class' => 'btn btn-success', 'escape' => false)
);
Add the disabled class to your button:
<?php
echo $this->Html->link(
$this->Html->tag('span', '', array('class' => 'glyphicon glyphicon-ok')) . " Finalizar",
array(
'controller' => 'Questoes',
'action' => 'limparSession'
),
array(
'role' => 'button',
'class' => 'btn btn-success disabled',
'escape' => false
)
);
?>
This is a bootstrap feature related to the given class.
If you want to do it without bootstrap:
<?php
echo $this->Html->link(
$this->Html->tag('span', '', array('class' => 'glyphicon glyphicon-ok')) . " Finalizar",
array(
'controller' => 'Questoes',
'action' => 'limparSession'
),
array(
'role' => 'button',
'class' => 'btn btn-success',
'disabled' => 'disabled',
'escape' => false
)
);
?>
echo $this->Form->button(
$this->Html->tag('span', '', array('class' => 'glyphicon glyphicon-ok'))." Finalizar",
array('type' => 'submit','onclick' => 'this.disabled=true;return true;',
'class' => 'btn disabled', 'escape' => false)
);
I am new in cakephp and i have to create a link with 2 tags like following html
<li><i class="fa fa-th-list"></i> <span>Shop</span></li>
And in cake php i did something like this:
<li><?php echo $this->Html->link(
// $this->Html->tag('i', array('class' => array('fa', 'fa-th-list'))),
$this->Html->tag('span', 'Video / Imagini', null),
array(
'controller' => 'users',
'action' => 'video',
),
array('escape' => FALSE)) ?></li>
How can i add the tag?
I search to internet and on cake book but no details about the second tag.
Thank you for your time.
Your code was almost correct. I made only some little changes:
<li><?php
echo $this->Html->link(
$this->Html->tag('i', '', array('class' => array('fa', 'fa-th-list'))) .
$this->Html->tag('span', 'Video / Imagini'),
array(
'controller' => 'users',
'action' => 'video',
),
array('escape' => false)
);
?></li>