I am using Yiistrap. I want to modify content of model - php

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', )); ?>

Related

Adding a dropdown menu in Prestashop 1.7 module

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?

CakePHP 3.x Change Label For Radio Buttons

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'
));
?>

Yii Booster popover over text rather than button

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',
))?>

Adding a label to a symfony 2 form field

I'm trying to modify a piece of code that generates an input field using the Symfony 2 framework. The thing he creates the field with a default label equals to the name id of the field, in this case; "amount".
<?php
//++++++++++ descrizione
echo $view['form'] -> row($form["amount"], array(
//widget
"widgetArgs" => array(
"attr" => array(
'class' => 'input-small tooltipRight',
'id' => "gift_amount"
),
"tooltip"=>"gift.tooltip.amount",
"translation_domain" =>"brand"
),
"labelArgs" => array(
"label_attr" => array(
'class' => 'control-label',
)) ,"rowType"=>2
)
);
?>
How can i edit this to make it show a custom label?
You have to add the label properties:
<?php
echo $view['form']->row($form["amount"], array(
'widgetArgs' => array(
"attr" => array(
'class' => 'input-small tooltipRight',
'id' => "gift_amount"
),
'tooltip'=>'gift.tooltip.amount',
'translation_domain' =>'brand'
),
'label' => 'My ammount',
));

dynamically add tab in YiiBooster TbTabs widget

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...

Categories