YII booster widget not appear in server - php

I need help here. I have a system developed with Yii framework. I used Yii Bootstrap and Yii Booster for the extensions. However, the booster widgets that I have implemented inside the system is not appearing when I uploaded the files into the LINUX server. It works fine in my laptop (development environment). The textarea, modal, tbselect2 all works well. However, it's not appear on the server side.
example:
//booster for tbckeditor
$this->widget('booster.widgets.TbCKEditor',array(
'model'=>$model, # Data-Model (form model)
'attribute'=>'content', # Attribute in the Data-Model
'editorOptions' => array(
'plugins' => 'basicstyles,toolbar,enterkey,entities,floatingspace,wysiwygarea,indentlist,list,dialog,dialogui,button,indent,fakeobjects',
)
) );
//booster for tbselect2
$this->widget('booster.widgets.TbSelect2',array(
'model' => $model,
'attribute' => 'job_cat_id',
'data' => CHtml::listData(AdmJobCat::model()->findAll(array('order'=>'jc_title ASC')), 'jc_id', 'jc_title'),
'options' => array('placeholder' => '--Please Select--','width' => '100%', 'allowClear'=>true,),
'htmlOptions' => array('multiple' => 'multiple'),
)
);
<?php $this->beginWidget('booster.widgets.TbModal', array('id' => 'withdrawModal')); ?>
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h4>Withdraw Application(s)</h4>
</div>
<div class="container-modal">
<?php
$this->renderPartial('form/_withdraw_form'); //calling external form
?>
</div>
<?php
$this->endWidget(); //end modal widget
?>

Related

Customizing the Templates FormHelper for just plugins CakePHP 3?

I would like to customize a form helper template for just a plugin, not across the App.
Example: 'inputContainer' => '<div class="form-control">{{content}}</div>',
How do I go about doing this in CakePHP 3?
As per the docs - to change theme inline at runtime use setTemplate:
$myTemplates = [
'inputContainer' => '<div class="form-control">{{content}}</div>',
];
?>
<?= $this->Form->create('Users') ?>
<? $this->Form->setTemplates($myTemplates); ?>
<?=
$this->Form->input('email', [
'class' => 'form-control',
'templates' => [
'formGroup' => '{{input}}{{label}}'
]])
?>
You can't use the templates option on the Form for a dynamic template, it will only look for a config file listing template items in /config.

How to use FormHelper::postLink() inside of a form?

I want to create a Cakephp delete post link within form like the following. But the very first delete post button doesn't include delete Form when I inspect in browser and can't delete but the others include as I want and can delete.
Is it cakephp bug or something I need to change my source code?
<?php
echo $this->Form->create('Attendance', array('required' => false, 'novalidate' => true));
foreach($i = 0; $i < 10; i++):
echo $this->Form->input('someinput1', value => 'fromdb');
echo $this->Form->input('someinput2', value => 'fromdb');
echo $this->Form->postLink('Delete',array('action'=>'delete',$attendanceid),array('class' => 'btn btn-dark btn-sm col-md-4','confirm' => __('Are you sure you want to delete')));
endforeach;
echo $this->Form->button('Submit', array('class' => 'btn btn-success pull-right'));
echo $this->Form->end();
?>
Forms cannot be nested, the HTML standard forbids that by definition. If you try to, most browsers will drop the nested form and render its contents outside of the parent form.
If you need post links inside of existing forms, then you must use the inline or block options (available as of CakePHP 2.5, inline has been removed in CakePHP 3.x), so that the new form is being set to a view block that can be rendered outside of the main form.
CakePHP 2.x
echo $this->Form->postLink(
'Delete',
array(
'action' => 'delete',
$attendanceid
),
array(
'inline' => false, // there you go, disable inline rendering
'class' => 'btn btn-dark btn-sm col-md-4',
'confirm' => __('Are you sure you want to delete')
)
);
CakePHP 3.x
echo $this->Form->postLink(
'Delete',
[
'action' => 'delete',
$attendanceid
],
[
'block' => true, // disable inline form creation
'class' => 'btn btn-dark btn-sm col-md-4',
'confirm' => __('Are you sure you want to delete')
]
);
Close the main form and output post link forms
// ...
echo $this->Form->end();
// ...
echo $this->fetch('postLink'); // output the post link form(s) outside of the main form
See also
CakePHP 2.x
API > FormHelper::postLink()
Cookbook > Views > Using view blocks
CakePHP 3.x
API > \Cake\View\Helper\FormHelper::postLink()
Cookbook > Views > Helpers > Form > Creating Standalone Buttons and POST links
Cookbook > Views > Using View Blocks

Yii Sort By Clistview not working

I'm using Yii 1.1.15. I got to my CListView to populate the table correctly on page load. but when i try to sort the table by store name the ajax response is the html for the whole page. and the table is empty.
but when i refresh the page &sort=store or &sort=store.desc the page works fine and sorts proper too. Any ideas what i'm doing wrong?
In my Controller
$dataProvider=new CActiveDataProvider('Store',
array(
'criteria' => array(
'condition'=>$_search_conditions,
'params'=>$search_params,
),
'sort'=>array(
'defaultOrder'=>'store DESC',
'attributes'=>array(
'store'=>array(
'asc'=>'store',
'desc'=>'store DESC',
),
'*',
)
),
)
);
$model = new Store;
$model->unsetAttributes(); // clear any default values
//render page
$this->render('index',array(
'dataProvider'=>$dataProvider,
'model'=>$model
));
In my View
$this->widget('zii.widgets.CListView', array(
'id' => 'store-list',
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'enableHistory'=> true,
'pagerCssClass' => 'pagination',
'ajaxUpdate'=>'store-list',
'loadingCssClass' => '', //remove loading icon
'sortableAttributes'=>array(
'store',
//'state' => 'State',
//'distance' => 'Distance'
),
'emptyText' => '<div class="alert alert-info">No data found</div>',
'template'=>'
<div class="row">
<div class="col-md-12">
<div class="pull-left visible-lg visible-md visible-sm">{summary}</div>
<div class="pull-right">{sorter}</div>
</div>
</div>
<div class="row">
<div class="col-md-12">{items}</div>
</div>
<div class="row">
<div class="col-md-12">
{pager}
</div>
</div>',
'pager' => array('id'=>'_pagination',
'class' => 'LinkPager',
'header' => '', //remove pagination header
'htmlOptions'=>array('class'=>'pagination') //add bootstrap pagination class
),
));
also in my function parseUrl() i have this code which does echo the correct value for $_GET['Store_sort'] the code below is used in my custom url manager class
if (!empty($_GET['sort']))
{
echo $_GET['Store_sort'] = $_GET['sort'];
}
UPDATE: even with friendly url disabled it does not sort. here is the URL of the ajax post. The pagination doesnt work either
http://localhost/dev/frontend/www/store/store/index/?Store_sort=store.desc&ajax=store-list

how to pass a php variabe to yiibooster modal window via link

I want to pass a php variable to modal window , what i am doing is opening a modal window using this link , but i want to pass a variable to this link and get same variable in modal window , i try to to do this to append a text in some div but it return html that i am unable to get in query
echo CHtml::link(
'Set Recipe', '', array(
'class' => 'testclass',
'id' => $finalDate,
'data-toggle' => 'modal',
'data-target' => '#myModal',
'fahadVar' => $finalDate
));
and when i click this button i got modal window how to get variable set in button
Here is simple modal code of yiibooster
<div class="modal-body">
<p>One fine body...</p>
</div>
<div class="modal-footer">
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'type' => 'primary',
'label' => 'Save changes',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
<?php $this->widget(
'bootstrap.widgets.TbButton',
array(
'label' => 'Close',
'url' => '#',
'htmlOptions' => array('data-dismiss' => 'modal'),
)
); ?>
</div>
<?php $this->endWidget(); ?>
thanks in advance
You should create a Widget.
Note: I copied below from another post. It works like charm.
First Create a new widget. Let say the name is CategoryWidget. Put this widget under components directory protected/components.
class CategoryWidget extends CWidget {
public function run() {
$models = Category::model()->findAll();
$this->render('category', array(
'models'=>$models
));
}
}
Then create a view for this widget. The file name is category.php. Put it under protected/components/views
category.php
<?php if($models != null): ?>
<ul>
<?php foreach($models as $model): ?>
<li><?php echo $model->name; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Then call this widget from your main layout.
main.php
// your code ...
<?php $this->widget('CategoryWidget') ?>

FancyBox like in gii module

I want a FancyBox like that one in the gii module code generator. I have downloaded the EFancyBox extension and made it run. The first time when i press the link the fancybox is properly displayed and i close it, but when i try the second time a blank window appears with no content. Here is the code:
<?php echo CHtml::link($url,"#data", array('id'=>'iframe')); ?>
<div style="display:none">
<div id="data"><iframe src="<?php echo $url; ?>"
frameborder=0 width=1024 height=768 scrolling=yes></iframe></div> </div>
<?php $this->widget('application.extensions.fancybox.EFancyBox',
array( 'target'=>'a#iframe', 'config'=>array( 'scrolling' => 'no', 'titleShow' => true, ), ) ); ?>
</div>
I have found the solution:
<?php $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a#iframe', 'config'=>array( 'scrolling' => 'no', 'titleShow' => true, 'onClosed'=>"js:function(){parent.location.reload(true);}" ), ) ); ?>
It seems ok to me, because when you reload the data you need to tell to the fancybox the new dom elements, when you reload you tell the new elements, its ok like that.
<?php $this->widget('application.extensions.fancybox.EFancyBox', array( 'target'=>'a#iframe', 'config'=>array( 'scrolling' => 'no', 'titleShow' => true, 'onClosed'=>"js:function(){parent.location.reload(true);}" ), ) ); ?>

Categories