gunnit
(Maric Gregor)
July 5, 2012, 1:50pm
1
i came across a little quest i am trying to convert this link that i worte in YII into a yii.bootstrap button but with very little success. I looked for a solution in the documentation on the bootstrap page but with no results so iam hoping someone here will point me in the right direction.
so the code for the link is as follows :
<?php echo CHtml::link(
'delete',
'#',
array(
'submit'=>'',
'params'=>array(
'Price[command]'=>'delete',
'Price[id]'=>$id,
'noValidate'=>true)
));?>
The code for the yiibotstrap button is as follows :
<?php $this->widget(‘bootstrap.widgets.BootButton’, array(
'buttonType'=>'submit',
'type'=>'primary',
'icon'=>'ok white',
'label'=>'Submit',
// '', 'large', 'small' or 'mini'
)); ?>
By the way iam programming in YII (php framework)
fatz
(Fabrice Tz)
July 5, 2012, 4:46pm
2
I’m not sure, but have you tried something like :
<?php $this->widget('bootstrap.widgets.BootButton', array(
'label'=>'Submit',
'buttonType' => 'link',
'url'=>array('#', 'Price[command]'=>'delete', 'Price[id]'=>$id, 'noValidate'=>true),
'type'=>'primary',
'icon'=>'ok white',
)); ?>
But if your button is really a submit button, then it should be inside a form and automatically send the parameters from the form. Hope this helps…
Cheers,
fatz
gunnit
(Maric Gregor)
July 6, 2012, 8:09am
3
fatz:
I’m not sure, but have you tried something like :
<?php $this->widget('bootstrap.widgets.BootButton', array(
'label'=>'Submit',
'buttonType' => 'link',
'url'=>array('#', 'Price[command]'=>'delete', 'Price[id]'=>$id, 'noValidate'=>true),
'type'=>'primary',
'icon'=>'ok white',
)); ?>
But if your button is really a submit button, then it should be inside a form and automatically send the parameters from the form. Hope this helps…
Cheers,
fatz
Thanks for your reply your approach works i just tried it out but if anyone else is interested in the following way it also works <?php
$this->widget(‘bootstrap.widgets.BootButton’, array(
'buttonType'=>'submitLink',
'type'=>'danger',
'icon'=>'trash',
'label'=>'Delete',
'htmlOptions'=>array(
'submit'=>'',
'params'=>array(
'Price[command]'=>'delete',
'Price[id]'=>$id,
'noValidate'=>true)
),
)); ?>
gunnit
(Maric Gregor)
July 6, 2012, 8:18am
4
i have an even more challanging question how could i convert the following code into a bootstrap button :
$this->widget(‘Relation’, array(
'model' => $model,
'relation' => 'products',
'parentObjects' => Product::model()->findAll('id_contract='.$model->id_contract),
'fields' => 'product_name',
'showAddButton' => false,
));?>