Yii booster documentation shows how to make a popover over a button. I want to create one over an anchor element rather than a button. Essentially I want to combine the popover with Yii's tooltip. Does anyone know how to do this?
This is the code for the pop-over:
$this->widget(
'bootstrap.widgets.TbButton',
array(
'label' => 'Top popover',
'type' => 'primary',
'htmlOptions' => array(
'data-title' => 'A Title',
'data-placement' => 'top',
'data-content' => "And here's some amazing content. It's very engaging. right?",
'data-toggle' => 'popover'
),
));
If there was a way of altering this to not render a button, but just an anchor the problem would be solved, but I can't find anything in the code that I can use to do this.
Update
Following Sergey's answer, here's what I've put:
echo CHtml::Link("$detail->text", null,
array(
'rel' => 'popover',
'data-trigger' => "hover",
'data-title' => "$header",
'data-content' => "$body"
));
This is close to what I need, but for some reason the hove doesn't work, only the click and also only the content get's displayed not the title.
You can use CHtml:
<?php echo CHtml::Link('<i class="icon-info-sign"></i>', null, [
'rel' => 'popover',
'data-trigger' => 'hover',
'data-title' => 'Your title',
'data-content' => 'Your content',
])?>
Update:
For Bootstrap 2.3.2 :
<?php Yii::app()->clientScript->registerScript("", "$('.ipopover').popover();", CClientScript::POS_READY) ?>
<?php echo CHtml::Link('<i class="icon-info-sign"></i>', null, array(
'class' => 'ipopover',
'data-trigger' => 'hover',
'data-title' => 'Your title',
'data-content' => 'Your content',
))?>
Related
I'm so beginner in Prestashop 1.7, I wanted to add a dropdown select section in my banner module to select the way to open the banner link.
but the selected value is never passed to the HTML, the code below IS passed but the one under isn't, can you please assist me?
[enter image description here][1]
array(
'type' => 'text',
'lang' => true,
'label' => $this->trans('Banner description', array(), 'Modules.Banner.Admin'),
'name' => 'BANNER_DESC',
'desc' => $this->trans('Please enter a short but meaningful description for the banner.', array(), 'Modules.Banner.Admin')
)
array(
'type' => 'select', //select
'lang' => true,
'label' => $this->trans('Banner tab', array(), 'Modules.Banner.Admin'),
'name' => 'BANNER_TAB',
'required'=>'true',
'options' => array(
'query' => array(
array('key' => '_blank', 'name' => 'New tab'),
array('key' => '_self', 'name' => 'Same tab'),
),
'id' => 'key',
'name' => 'name'
),
'desc' => $this->trans('Please select the way to open the link.', array(), 'Modules.Banner.Admin')
)
This is how it looks in the Backoffice:
Here
You not only need to add a new field to your form but also handle saving the data from it.
Take a look at a few examples:
https://github.com/PrestaShop/ps_featuredproducts/blob/dev/ps_featuredproducts.php#L122
Notice how the module author managed to save each configuration field from the form. This is what you need to do.
If you want to have access to data in your view, you have to pass it:
https://github.com/PrestaShop/ps_featuredproducts/blob/dev/ps_featuredproducts.php#L244
Maybe after you added a new field, you forgot to handle the saving + passing to the view?
I am attempting to create several radio buttons with a specific label...
I am using the following code, however, there is no label
echo $this->Form->radio('qualify', [['value' => 1, 'text' => 'Yes'], ['value' => 0, 'text' => 'No']], ['label' => 'Qualify Only']);
Any ideas on how I can get the label to show up for these radio buttons?
<?php
$qualify = [['value'=>'0','text'=>'No'],['value'=>'1','text'=>'Yes']];
echo $this->Form->input('qualify', array(
'options' => $qualify,
'type' => 'radio',
'placeholder' => 'Qualify Only'
));
?>
This code will be able to pick any existing value in the edit view.
You can still use the $this->Form->input and put a type whether its a select or radio
<?php
$qualify = ['0' => 'No', '1' => 'Yes'];
echo $this->Form->input('qualify', array(
'options' => $qualify,
'type' => 'radio',
'placeholder' => 'Qualify Only'
));
?>
I am using Yiistrap. I want to modify content of model. I want to add some label, text box, drop-down (2 or more fields). I have given the code below & mentioned the region which I want to modify.
<?php $this->widget('bootstrap.widgets.TbModal', array(
'id' => 'myModal',
'header' => 'Modal Heading',
'content' => '<p>I Wnat to Modify this region</p>', /* Here I don't want only plain text i.e. <p> tag. I want to Add label as well as textbox, dropdown. please help me */
'footer' => implode(' ', array(
TbHtml::button('Save Changes', array(
'data-dismiss' => 'modal',
'color' => TbHtml::BUTTON_COLOR_PRIMARY)
),
TbHtml::button('Close', array('data-dismiss' => 'modal')),
)), )); ?>
<?php echo TbHtml::button('Click me to open modal', array(
'style' => TbHtml::BUTTON_COLOR_PRIMARY,
'size' => TbHtml::BUTTON_SIZE_LARGE,
'data-toggle' => 'modal',
'data-target' => '#myModal', )); ?>
Yii bootstrap widgets TbDatePicker not hiding after select a date.
<?php
echo $form->labelEx($modelRenterStatus,'moving_date');
$this->widget('bootstrap.widgets.TbDatePicker', array(
'model' => $modelRenterStatus,
'attribute' => 'moving_date',
'options' => array(
'size' => '10', // textField size
'maxlength' => '10', // textField maxlength
'autoclose' => true,
),
));
?>
what's wrong with my this code?
According to YB Docs Options are
options for the original library. This value will be JSON-encoded and
fed to bootstrap-datepicker
And looking into library docs here I can't see the options you have put and so they are invalid.
Taking example from YB site
$this->widget(
'bootstrap.widgets.TbDatePicker',
array(
'name' => 'some_date_jap',
'options' => array(
'language' => 'ja'
))
);
language is option in original library. So recheck it again!
Just to expand my answer here is one that works with my form
<?php
echo $form->datepickerRow($model, 'mode_attribute_here',array('hint'=>'',
'prepend'=>'<i class="icon-calendar"></i>',
'options'=>array('format' => 'yyyy-mm-dd' , 'weekStart'=> 1)
)); ?>
maybe it help others!!
More detail here
<?php
echo $form->labelEx($modelRenterStatus,'moving_date');
$this->widget('bootstrap.widgets.TbDatePicker', array(
'model' => $modelRenterStatus,
'attribute' => 'moving_date',
'options' => array(
'size' => '10', // textField size
'maxlength' => '10', // textField maxlength
'autoclose' => true,
),
));
?>
I have created bootstrap.widgets.TbTabs as below, how can I add a new tab dynamically on client side. Is there any event using which I can add new tab just like the "shown" event in below code.
<?php $this->widget('bootstrap.widgets.TbTabs', array(
'id' => 'mytabs',
'type' => 'tabs',
'tabs' => array(
array('id' => 'tab1', 'label' => 'Tab 1', 'content' => $this->renderPartial('tab1', null, true), 'active' => true),
array('id' => 'tab2', 'label' => 'Tab 2', 'content' => 'loading ....'),
array('id' => 'tab3', 'label' => 'Tab 3', 'content' => 'loading ....'),
),
'events'=>array('shown'=>'js:loadContent')
));?>
There is none but that doesn't mean you can't create it yourself.
Just pass the 'tabs' part via your controller, something like this:
in your controller:
$tabs => array(
array('id' => 'tab1', 'label' => 'Tab 1', 'content' => $this->renderPartial('tab1', null, true), 'active' => true),
array('id' => 'tab2', 'label' => 'Tab 2', 'content' => 'loading ....'),
array('id' => 'tab3', 'label' => 'Tab 3', 'content' => 'loading ....'),
);
$this->render('pageName', array('tabs' => $tabs));
In your view:
<?php $this->widget('bootstrap.widgets.TbTabs', array(
'id' => 'mytabs',
'type' => 'tabs',
'tabs' => $tabs,
'events'=>array('shown'=>'js:loadContent')
));?>
If you want to achieve something similar but in your main layout, you can create a Model which extends from CActiveRecord and stores the tabs in the database. After that you could use a static method in your model class to call and retrieve the tabs. Then in your layout view you can do something like this:
<?php $this->widget('bootstrap.widgets.TbTabs', array(
'id' => 'mytabs',
'type' => 'tabs',
'tabs' => Model::getTabs(),
'events'=>array('shown'=>'js:loadContent')
));?>
Add the new tab link in header, add the new tab, display the new tab
$('#tabHeaders').append($('<li>New Tab</li>'));
$('#tabContent').append($('<div class="tab-pane" id="newtab"></div>'));
$('#newtab').tab('show');
Note YiiBooster automatically generates element id, you need to use appropriate jquery selectors
I don't think it's good practice to renderPartial the included views inside the controller.
I found this to work for me in the view:
$this->widget('bootstrap.widgets.TbTabs', array(
'type'=>'tabs',
'tabs'=>array(
array( //
'label'=>'Comments ('.$model->commentCount.')',
'content'=>$this->renderPartial( '_comments', array( 'model'=>$model ), true ),
),
)
));
Obviously, for this to work you need "_comments.php" to exist...