YiiBooster Redactor editor options - yii-extensions

I've been looking at what the correct way is to specify the editor options within Redactor using the YiiBooster widget. I'm using the following code:
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id' => 'item-form',
'enableAjaxValidation' => false,
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
));
<?php echo $form->redactorRow($model, 'description', array(
'buttons' =>
'formatting', '|', 'bold', 'italic', 'deleted', '|', 'alignment', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent'
)); ?>
But it still seems to return the default settings. Would anyone be able to point me in the right direction please.
Thanks
Jonny

Found out the answer!
<?php echo $form->redactorRow($model, 'description', array(
'options' => array(
'minHeight' => 200,
'buttons' => array(
'formatting', '|', 'bold', 'italic', 'deleted', '|', 'alignment', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent')
)
));
Hope that is of help to someone!

For yiibooster 4.x.x:
<?php echo $form->redactorGroup($model, 'content', array(
'widgetOptions' => array(
'editorOptions' => array(
'minHeight' => 200,
'buttons' => array(
'formatting', '|', 'bold', 'italic', 'deleted', '|', 'alignment', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent'
)
)
)
)); ?>

Related

How to add placeholder text to yii inputfield?

iam using clevertech an extension for YII, dose anybody know how i can add my own custom placeholder text inside the input.
Below is an example of the input filed:
<?php echo $form->textFieldGroup(
$model,
'textField',
array(
'wrapperHtmlOptions' => array(
'class' => 'col-sm-5',
),
'hint' => 'In addition to freeform text, any HTML5 text-based input appears like so.'
)
); ?>
You can add placeholder to you html attributes, as follows:
<?php echo $form->textFieldGroup(
$model,
'textField',
array(
'wrapperHtmlOptions' => array(
'class' => 'col-sm-5',
),
'hint' => 'In addition to freeform text, any HTML5 text-based input appears like so.',
'widgetOptions' => array(
'options' => array(
'placeholder' => 'Placeholder content',
),
),
)
); ?>
See http://yiibooster.clevertech.biz/widgets/forms/view/activeform.html
Try this...
<?php echo $form->textFieldGroup(
$model,
'textField',
array(
'wrapperHtmlOptions' => array(
'class' => 'col-sm-5',
),
'widgetOptions'=>array(
'htmlOptions'=>array('placeholder' => 'Placeholder content')
)
'hint' => 'In addition to freeform text, any HTML5 text-based input appears like so.'
)
); ?>

dependent dropdownlistGroup Yii Booster

I just learning Yiibooster recently and stuck with this..
I have a dependent dropdownlistgroup using yii booster with ajax so kelas data will be generated after matkul selected. It works fine if i using dropdownlist from yii but i want a nice form using Yiibooster form.
<?php
echo $form->dropDownListGroup(
$model,
'matkul',
array(
'wrapperHtmlOptions' => array(
'class' => 'col-sm-5',
),
'widgetOptions' => array(
'data' => $matkullist,
'htmlOptions' => array('multiple' => false),
),
'prompt'=>'Select',
array(
'ajax'=> array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Kp/Getkelas'), //url to call.
'update'=>'#'.CHtml::activeId($model,'kelas'), //selector to update
)
)
)
); ?>
<?php echo $form->dropDownListGroup(
$model,
'kelas',
array(
'wrapperHtmlOptions' => array(
'class' => 'col-sm-5',
),
'widgetOptions' => array(
'htmlOptions' => array('multiple' => false),
)
)
);?>
The problem is the ajax does not work when i use dropdownlistgroup, when i test it with normal dropdownlist like below code its work normal, sorry for my english.
echo CHtml::dropDownList('country_id','', array(1=>'USA',2=>'France',3=>'Japan'),
array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Kp/Getkelas'), //url to call.
'update'=>'#city_id', //selector to update
)));
echo CHtml::dropDownList('city_id','', array());
I'm not hear about the function dropdownListGroup.
using Yiibooster, you can add the dropdown as,
$this->widget(
'booster.widgets.TbSelect2',
array(
'asDropDownList' => false,
'name' => 'clevertech',
'options' => array(
'tags' => array('clever', 'is', 'better', 'clevertech'),
'placeholder' => 'type clever, or is, or just type!',
'width' => '40%',
'tokenSeparators' => array(',', ' ')
)
)
);
ref link : http://yiibooster.clevertech.biz/widgets/forms_inputs/view/select2.html
You should put ajax options in widgetOptions -> htmlOptions -> ajax
$form->dropDownListGroup($model, 'beer', array(
'widgetOptions' => array(
'data' => CHtml::listData(Beer::model()->findAll(), 'id', 'name'),
'htmlOptions' => array(
'ajax' => array(
'type' => 'POST',
'url' => Yii::app()->createUrl('/beer'),
'update' => '#beer',
)
),
)
);
not most efficient solution but it works,
looking the html at the end, we have
<div class="form-group">
<?php echo $form->labelEx($model,'matkul',array('class' => 'col-sm-3 control-label')); ?>
<div class="col-sm-5 col-sm-9">
<?php echo $form->dropDownList($model,'matkul',$matkullist รณ array(),
array('class' => 'form-control','ajax'=>array('type'=>'POST','url'=>CController::createUrl('Kp/Getkelas'),'update'=>'#'.CHtml::activeId($model,'kelas')),'empty'=>'Select')); ?>
<?php echo $form->error($model,'matkul'); ?>
</div>
</div>
important is that 'class' put the html class, 'class' => 'col-sm-3 control-label' and 'class' => 'form-control', for dropDownList

Yii ESelect2 extension show preselected valued

i want to show already selected values in tags of ESelected extension but unable to find any solution my code in update form in view is
$this->widget('ext.select2.ESelect2', array(
'name' => 'cat_names[]',
'data' => Coupon::getCategories(),
'options' => array(
'placeholder' => '',
'allowClear' => true,
),
'htmlOptions' => array(
'multiple' => 'multiple',
),
));
if i add tags fields in option of Eselect it changes the behaviour and stop working i add tags in options like this
'tags' => Coupon::getCategories_old(),
Any suggestion will be helpfull thanks in advance
$this->widget('ext.select2.ESelect2', array(
'name' => 'cat_names[]',
'value'=> array(91,95),
'data' => Coupon::getCategories(),
'options' => array(
'placeholder' => '',
'allowClear' => true,
),
'htmlOptions' => array(
'multiple' => 'multiple',
),
));

How to link to new blank page in tbbuttongroup yii

Given tbbuttongroup when user clicks the items I want to open a link to new blank page. I've tried the code below but it doesn't work.
<?php
$this->widget(
'bootstrap.widgets.TbButtonGroup',
array(
'type' => 'primary',
// '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons' => array(
array('label' => 'Action', 'url' => '#'),
array(
'items' => array(
array(
'label' => 'Cetak ke Pdf',
'url' => array("Tbpinjaman/cetakpdf",id=>$_GET[id]),
'target'=>'_blank',
),
array('label' => 'Export ke Excel', 'url' => 'Tbpinjaman/admin'),
)
),
),
)
);
<?php
$this->widget(
'bootstrap.widgets.TbButton', array(
'url'=> 'http://stackoverflow.com/',
'label'=>Yii::t('strings', 'stackoverflow'),
'htmlOptions' => array('target'=>'_blank')
));
?>
target on button widget must be put on htmloptions :
'htmlOptions' => array('target'=>'_blank')
Use linkOptions for your anchor items
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/cetakpdf/$_GET[id]','Your window name','width=500,height=700'); return false;"
)
Your code will come like this.
<?php
$this->widget('bootstrap.widgets.TbButtonGroup', array
(
'type' => 'primary',
'buttons' => array
(
array('label' => 'Action', 'url' => '#', 'htmlOptions' => array('id' => 'buttonStateful'),),
array
(
'items' => array
(
array
(
'label' => 'Cetak ke Pdf',
'url' => '#',
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/cetakpdf/$_GET[id]','Your window name','width=500,height=700'); return false;"
)
),
array
(
'label' => 'Export ke Excel',
'url' => '#',
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/admin','Your window name','width=500,height=700'); return false;"
)
)
)
)
)
));
?>
Try this :
<?php
$this->widget(
'bootstrap.widgets.TbButtonGroup',
array(
'type' => 'primary',
// '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons' => array(
array('label' => 'Action', 'url' => '#'),
array(
'items' => array(
array(
'label' => 'Cetak ke Pdf',
'url' => array("Tbpinjaman/cetakpdf",id=>$_GET[id]),
**'htmlOptions' => array('target'=>'_blank'),**
),
array('label' => 'Export ke Excel', 'url' => 'Tbpinjaman/admin'),
)
),
),
)
);

Yii CGridView custom footer

I am using CGridView to show data in grid format, but i am not able to create a custom footer,
the code that i am using,
<?php
$this->widget('zii.widgets.grid.CGridView',
array('dataProvider' => $dataProvider,
'columns' => array(
array(
'name' => 'created_date',
'header' => 'Created',
),
array(
'name' => 'access_date',
'header' => 'Accessed',
),
array(
'name' => 'referenceCode',
'header' => 'Ref Code',
),
array(
'name' => 'designation',
'header' => 'Designation',
),
array(
'name' => 'company',
'header' => 'Company',
),
array(
'name' => 'recommended_actions',
'header' => 'Recommended Action',
'type' => 'html',
'value' => function($jobBoard) {
return CHtml::link($recAction[0]['display_text'], Yii::app()->createUrl($actionUrl, $params));
}
),
array(
'class' => 'CDataColumn',
'header' => 'List of Actions',
'type' => 'html',
'value' => function($jobBoard){
echo '<div class="action-joborder">
<ul class="moveto-joborder">
<li>Action <img height="6" width="7" alt="" src="images/bg_action.gif">
<ul>';
echo '<li>'.CHtml::link($actionArray['display_text'], Yii::app()->createUrl($actionUrl, $params)).'</li>';
echo '</ul>
</li>
</ul>
</div>';
},
'name' => 'actions',
),
)));
?>
the above code gives me footer with pagination only, i want to place a some Button element to give the grid some control.
the grid should look like,
is there any way i can make custom element at the footer.
You can extend framework/zii/widgets/grid/CGridView.php and use it in your code. extend the following method to change footer
public function renderTableFooter()
{
$hasFilter=$this->filter!==null && $this->filterPosition===self::FILTER_POS_FOOTER;
$hasFooter=$this->getHasFooter();
if($hasFilter || $hasFooter)
{
echo "<tfoot>\n";
if($hasFooter)
{
echo "<tr>\n";
foreach($this->columns as $column)
$column->renderFooterCell();
echo "</tr>\n";
}
if($hasFilter)
$this->renderFilter();
echo "</tfoot>\n";
}
}
protected/components/GridView.php
Yii::import('zii.widgets.grid.CGridView');
class GridView extends CGridView
{
/**
* Renders the table footer.
*/
public function renderTableFooter()
{
$hasFilter=$this->filter!==null && $this->filterPosition===self::FILTER_POS_FOOTER;
$hasFooter=$this->getHasFooter();
if($hasFilter || $hasFooter)
{
echo "<tfoot>\n";
if($hasFooter)
{
echo "<tr>\n";
foreach($this->columns as $column){
if($column->footer!='')
$column->footer=eval("return " . $column->footer.";");
$column->renderFooterCell();
}
echo "</tr>\n";
}
if($hasFilter)
$this->renderFilter();
echo "</tfoot>\n";
}
}
public function sumTotal($attribute){
$data=$this->dataProvider->getData();
$sum=0;
foreach($data as $index => $value ){
if(isset($data[$index]->{$attribute}))
$sum+=$data[$index]->{$attribute};
}
return $sum;
}
}
views/{controllers}/{action}.php
$this->widget('GridView',
array('dataProvider' => $dataProvider,
'columns' => array(
array(
'name' => 'created_date',
'header' => 'Created',
),
array(
'name' => 'access_date',
'header' => 'Accessed',
),
array(
'name' => 'referenceCode',
'header' => 'Ref Code',
),
array(
'name' => 'designation',
'header' => 'Designation',
),
array(
'name' => 'company',
'header' => 'Company',
),
array(
'name' => 'recommended_actions',
'header' => 'Recommended Action',
'type' => 'html',
'value' => function($jobBoard) {
return CHtml::link($recAction[0]['display_text'], Yii::app()->createUrl($actionUrl, $params));
}
'footer'=> 'number_format($this->sumTotal("recommended_actions"))',
),
array(
'class' => 'CDataColumn',
'header' => 'List of Actions',
'type' => 'html',
'value' => function($jobBoard){
echo '<div class="action-joborder">
<ul class="moveto-joborder">
<li>Action <img height="6" width="7" alt="" src="images/bg_action.gif">
<ul>';
echo '<li>'.CHtml::link($actionArray['display_text'], Yii::app()->createUrl($actionUrl, $params)).'</li>';
echo '</ul>
</li>
</ul>
</div>';
},
'name' => 'actions',
),
)));