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); ?>
Related
I have a gridview with pjax.
<div class="request-index">
<div id="ajaxCrudDatatable">
<?=
GridView::widget([
'id' => 'crud-datatable',
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'pjax' => true,
'columns' => require(__DIR__ . '/_columns.php'),
'toolbar' => [
['content' =>
Html::a('<i class="glyphicon glyphicon-plus"></i> Add Request', ['create'], ['role' => 'modal-remote', 'title' => 'Create new Requests', 'class' => 'btn btn-success']) .
Html::a('<i class="glyphicon glyphicon-repeat"></i> Reload', [''], ['data-pjax' => 1, 'class' => 'btn btn-primary', 'title' => 'Reset Grid']) .
'{toggleData}' .
'{export}'
],
],
'panel' => [
'type' => 'primary',
'heading' => '<i class="glyphicon glyphicon-list"></i> Requests listing',
'before' => '<button type="button" class="btn btn-danger btn-secondary"> Belum Selesai : <strong>'. $count_request_belum_selesai .'</strong> </button>',
'after' => BulkButtonWidget::widget([
'buttons' => Html::a('<i class="glyphicon glyphicon-trash"></i> Delete All', ["bulk-delete"], [
"class" => "btn btn-danger btn-xs",
'role' => 'modal-remote-bulk',delete this item'
]),
]) .
'<div class="clearfix"></div>',
]
])
?>
</div>
if you see from code above, please concern with
'before' => '<button type="button" class="btn btn-danger btn-secondary"> Not finished : <strong>'. $count_request_belum_selesai .'</strong> </button>',
When this button is clicked, I want to running a function in my model named RequestSearch :
public function searchRequestBelumSelesai(){
$query = Request::findAll(['tanggal_selesai' => NULL]);
return $query;
}
Which is the gridview will be displayed the result, is it possible ?
In the action of the controller that will receive the click of your button, you must modify the dataProvider given to the View, so that it looks like something like this:
$dataProvider= new ActiveDataProvider([
'query' => $your_model->searchRequestBelumSelesai(),
]);
Im using codeigniter, and I have a double form submission problem. I looked for a solution on google about 2-3 days ago, but I still didn't manage to find one. Can someone help me?
shopping_cart.php
<?php
echo anchor("user/item_all", "Continue to shopping", array(
'class' => 'btn btn-info'
));
if ($this->cart->total_items() > 0):
if ($return_checkout) {
echo anchor("user/checkout", "Checkout", array(
'class' => 'btn btn-success pull-right',
'style' => "margin-left: 10px",
));
}
echo anchor("user/destroy_cart", "Delete All Cart", array(
'class' => 'btn btn-danger',
'style' => "margin: 0px 10px"
));
echo form_button(array(
'type' => 'submit',
'class' => 'btn btn-primary pull-right',
'style' => "margin: 0px 10px",
'content' => "Update Cart"
));
endif;
?>
User.php
function checkout() {
$return_checkout = $this->session->userdata('poin') >= $this->cart->total() ? TRUE : FALSE;
$cart = $this->cart->contents();
if ($return_checkout AND count($cart) > 0) {
if ($this->mall->checkout($cart)) {
$this->cart->destroy();
redirect('user/shop_history');
}
}else
redirect('user/shop_history');
}
I hope someone can help me. Thanks in advance!
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
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'
)
);
?>
I've just started working with CakePHP and I want to create a form that when it is submitted it calls a function in the controller. I'm using CakePHP version 2.6
The Code I currently have is:
view:
<div class="modal-body">
<?php echo $this->Form->create('Tweet', array('url' => array('controller' => 'posts', 'action' => 'postTweet'))); ?>
<?php echo $this->Form->textarea('Tweet', array('class' => 'form-control','rows' => '3', 'placeholder' => "what's happening?", 'maxlength' => '140', 'label' => false)); ?>
<?php echo $this->Form->button('Close', array('class' => 'btn btn-default', 'data-dismiss' => 'modal', 'type' => 'button'));?>
<?php echo $this->Form->submit('Tweet', array('class' => 'btn btn-primary', 'type' => 'submit', 'div' => false)); ?>
<?php echo $this->Form->end(); ?>
</div>
PostsController:
public function postTweet(){
//check if post is being made
if ($this->request->is('post')) {
//do something
}
}
HTML on page:
<form action="/posts/postTweet" id="TweetIndexForm" method="post" accept-charset="utf-8">
<div style="display:none;">
<input name="_method" value="POST" type="hidden">
</div>
<textarea name="data[Tweet][Tweet]" class="form-control" rows="3" placeholder="what's happening?" maxlength="140" id="TweetTweet"></textarea>
<button class="btn btn-default" data-dismiss="modal" type="button">Close</button>
<input class="btn btn-primary" value="Tweet" type="submit">
</form>
The problem is when I click the submit button nothing happens, I've checked in Firebug and no errors are in the console tab, no POST is made in the network tab and there are also no errors logged to the error log. Any help will be great thanks.
EDIT:
Solved I had JavaScript preventing the form from being submitted Thanks for the help!
Use submit like ->
echo $this->Form->submit('Tweet', array('label' => false, 'name' => 'submit', 'class' => 'grayBTN', 'title' => '', 'alt' => 'Submit', 'error' => false));
It works I use it all the time .
The issue with your submit is 'type' => 'submit' is used in your code and you also specify $this->Form->submit too .
If you are specifying Button with type submit then its ok like ->
echo $this->Form->button('Submit Form', array('type' => 'submit'));
But in your case you have $this->Form->submit.. So you dont need to specify it explicitely.
try this
echo $this->Form->end(array('label' => 'Tweet','div' => false,'class' => 'btn btn-primary'));