I need two upload file with two upload view in one page with extension XUpload in Yii, but render first upload view.
$model = new MMediaUploadForm;
$url = aUrl('/project/media/upload', array('projectId' => $this->project->id));
$this->widget('uniprogy.extensions.xupload.XUpload', array(
'url' => $url,
'model' => $model,
'attribute' => 'file',
'downloadView' => $this->render('download', array('listWorkletId' => $this->getDOMId()), true),
'uploadView' => $this->render('upload', array(), true),
'uploadTemplate' => '#template-upload',
'formView' => $this->render('form', array(
'url' => $url,
'model' => $model,
'attribute' => 'file',
'htmlOptions' => array(
'id' => get_class($model) . "-form",
'enctype' => 'multipart/form-data',
),
), true),
));
$url1 = aUrl('/project/media/upload1', array('projectId' => $this->project->id));
$this->widget('uniprogy.extensions.xupload.XUpload', array(
'url' => $url1,
'model' => $model,
'attribute' => 'file',
'downloadView' => $this->render('download', array('listWorkletId' => $this->getDOMId()), true),
'uploadView' => $this->render('upload1', array(), true),
'uploadTemplate' => '#template-upload1',
'formView' => $this->render('form1', array(
'url' => $url1,
'model' => $model,
'attribute' => 'file',
'htmlOptions' => array(
'id' => get_class($model) . "-form",
'enctype' => 'multipart/form-data',
),
), true),
));
i have two text/x-tmpl with two id but just render first upload view!
help me plz thanks!
Related
My code:
echo $this->Form->create('Usps', array(
'inputDefaults' => array(
'label' => false,
'div' => false
),
'id' => 'form-validate',
'class' => 'form-horizontal',
'novalidate' => 'novalidate',
'url' => array('controller'=>'frondends','action' => 'tariffplan')
));
This produces www.example.com/frontends/tariffplan
I want to see : www.example.com/tariffplan
I changed url as follows:
'url' => array('action' => 'tariffplan')
but this produces :
www.example.com/usps/tariffplan
I searched google but no luck. Any help will be appreciated
Try this:
'url' => array('controller' => '/', 'action' => 'tariffplan')
I Want to open a CJuiModel by Clicking on CGridView CButtonColumn view Button as my CGridView and CJuiModel is as:-
<?php
$dataProvider = new CArrayDataProvider($model->exhibitorLocation, array(
'keys' => array('productId'),
));
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $dataProvider,
'id' => 'exhibitor-location-grid',
'summaryText' => false,
'pager' => array(
'class' => 'CLinkPager',
'header' => false,
),
'columns' => array(
array(
'header' => 'S No.',
'value' => '++$row',
),
array(
'header' => 'Hall No',
'value' => '$data->location->hallNo',
),
array(
'header' => 'Stand No',
'value' => '$data->standNo',
),
array(
'class' => 'CButtonColumn',
'header' => 'Manage',
'template' => '{view}{delete}',
'buttons' => array(
'view' => array(
'imageUrl' => $this->module->assetsUrl . "/images/info_icon.png",
'options' => array('class' => 'exb-location'),
'url' => 'Yii::app()->createUrl("admin/venuemap/viewExbLocation", array("exbLocId"=>$data->primaryKey))',
),
'delete' => array(
'imageUrl' => $this->module->assetsUrl . "/images/delete_icon.png",
'url' => 'Yii::app()->createUrl("admin/venuemap/deleteExbLocation", array("exbLocId"=>$data->primaryKey))',
),
),
'htmlOptions' => array(
'style' => 'width:100px;float:center'
)
),
),
'rowCssClassExpression' => '($row%2 ? "visit2" : "visit1")',
'itemsCssClass' => 'visitor_list',
'htmlOptions' => array(
)
));
?>
<div class="name_field">Hall No<span>*</span></div>
<?php echo CHtml::dropDownList('hall-no', '', CHtml::listData(Venuemap::model()->findAll(), 'locationId', 'hallNo'), array('class' => 'name_input2', 'id' => 'hall-no')); ?>
<div class="name_field">Stand No</div>
<?php echo CHtml::textField('Stand No', '', array('class' => 'name_input', 'id' => 'stand-no')); ?>
<?php
echo CHtml::ajaxLink("Add Location", Yii::app()->createUrl('admin/venuemap/addExbLocation'), array(
'type' => 'post',
'data' => array(
'exhibitorId' => $model->exhibitorId,
'standNo' => 'js: $("#stand-no").val()',
'locationId' => 'js: $("#hall-no").val()'
),
'success' => 'function(html){ $.fn.yiiGridView.update("exhibitor-location-grid"); }'
), array('class' => 'search_btn'));
?>
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id' => 'location-dialog',
'options' => array(
'title' => 'View Location',
'autoOpen' => false,
'modal' => true,
'width' => 'auto',
'height' => 'auto',
'resizable' => false
),
));
$this->endWidget();
?>
<?php
Yii::app()->clientScript->registerScript('view-location-ajax', "
$('.exb-location').click(function(){
url=$(this).attr('href');
$.ajax({
type: 'post',
url: url,
success: function(result){
$('#location-dialog').html(result).dialog('open');
$('#draggable').draggable();
return false;
}
});
return false;
});
");
?>
View Button is working fine and open a CJuiModel on click but when I add a new Location in CGridView .
On Clicking on view button my CJuiModel is not opening and page is redirecting to Url.Why my jquery is getting failed on updating CGridView. Help..
Change ajax call using JQuery 'on' instead direct event binding:
This:
...
$('.exb-location').click(function(){
...
Change for:
...
$('.exb-location').on('click', '.exb-location', function(){
...
Html Elements are destroyed and regenerated after CGridview refresh. Direct JQuery events only work with existing elements before DOM load. When they are removed, or new elements are added later, direct events don't work.
I'm building website using yii 1.1 framework and Clevertech YiiBooster extension.
Is there an easy way to render few "editable field" widgets inside the popover widget ?
Please see the code below. Any suggestions are welcome.
Main view:
....
$this->widget(
'booster.widgets.TbButton', array(
'label' => 'Right popover',
'context' => 'warning',
'buttonType' => 'button',
'size' => 'extra_small',
'htmlOptions' => array(
'id' => uniqid(),
'data-html' => true,
'data-title' => 'A Title',
'data-placement' => 'right',
'data-content' => $this->renderPartial('VIEW', array('data'=>$data), true, true),
'data-toggle' => 'popover'
),
)
);
....
partial view:
$this->widget('booster.widgets.TbEditableField', array(
'type' => 'text',
'model' => $survey,
'attribute' => 'text',
'pk' => 'pk',
'name' => 'name',
'text' => '',
'url' => $this->createUrl('controller/method/'), //url for submit data
'title' => 'text',
'placement' => 'right',
'id' => uniqid()),true);
$this->widget('booster.widgets.TbEditableField', array(
'type' => 'text',
'model' => $survey,
'attribute' => 'text',
'pk' => 'pk',
'name' => 'name',
'text' => '',
'url' => $this->createUrl('controller/method/'), //url for submit data
'title' => 'text',
'placement' => 'right',
'id' => uniqid()),true);
$this->widget('booster.widgets.TbEditableField', array(
'type' => 'text',
'model' => $survey,
'attribute' => 'text',
'pk' => 'pk',
'name' => 'name',
'text' => '',
'url' => $this->createUrl('controller/method/'), //url for submit data
'title' => 'text',
'placement' => 'right',
'id' => uniqid()),true);
I am using Yii Rights modules for ACL where I want pagination for Permissions page.
Following is my code:
In AuthItemController.php
public function actionPermissions() {
$dataProvider = new RPermissionDataProvider('permissions', array(
'pagination' => array(
'pageSize' => 10,
//'class' => 'CPagination', //showing an error
'itemCount' => 32
)));
// Get the roles from the data provider
$roles = $dataProvider->getRoles();
$roleColumnWidth = $roles !== array() ? 75 / count($roles) : 0;
// Initialize the columns
$columns = array(
array(
'name' => 'description',
'header' => Rights::t('core', 'Item'),
'type' => 'raw',
'htmlOptions' => array(
'class' => 'permission-column',
'style' => 'width:25%',
),
),
);
// Add a column for each role
foreach ($roles as $roleName => $role) {
$columns[] = array(
'name' => strtolower($roleName),
'header' => $role->getNameText(),
'type' => 'raw',
'htmlOptions' => array(
'class' => 'role-column',
'style' => 'width:' . $roleColumnWidth . '%',
),
);
}
$view = 'permissions';
$params = array(
'dataProvider' => $dataProvider,
'columns' => $columns,
);
// Render the view
isset($_POST['ajax']) === true ? $this->renderPartial($view, $params) : $this->render($view, $params);
}
And in View
$this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'bordered',
'dataProvider' => $dataProvider,
'template' => '{pager}{items}',
'emptyText' => Rights::t('core', 'No authorization items found.'),
'htmlOptions' => array('class' => 'grid-view permission-table'),
'columns' => $columns,
'pager' => array(
'header' => '',
'hiddenPageCssClass' => 'disabled',
'maxButtonCount' => 3,
'cssFile' => false,
'class' => 'CLinkPager',
'prevPageLabel' => '<i class="icon-chevron-left"></i>',
'nextPageLabel' => '<i class="icon-chevron-right"></i>',
'firstPageLabel' => 'First',
'lastPageLabel' => 'Last',
),
'pagerCssClass' => 'pagination',
));
I have already implemented pagination for other pages by using same method but here in rights module its not working. Its not showing any error but also not displaying pagination links/buttons.
I had the same problem when implementing multiple grids in one page, the solution that worked for me was , I checked the url the grid ajax call,and before update I manipulated the url, and set the correct url and parameters before ajax request!
like:
$this->widget('zii.grid.GridView', array(
'id' => 'group-grid-customers-list-not-scheduled',
'dataProvider' => $notScheduledVisitedDataProvider ,
'beforeAjaxUpdate' => '
function(id , options)
{
options.url = options.url.split("&test=test&");
options.url = options.url[0] + "&test=test&" + $(".search-form form").serialize();
}',
'columns' => array(
'col1',
'col2',
'col3',
),
));
I need to edit the following form so it will have attach file function:
function _getWriteForm()
{
$aForm = array(
'form_attrs' => array(
'name' => 'WallPostText',
'action' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'post/',
'method' => 'post',
'enctype' => 'multipart/form-data',
'target' => 'WallPostIframe',
'onsubmit' => 'javascript:return ' . $this->_sJsPostObject . '.postSubmit(this);'
),
'inputs' => array(
'content' => array(
'type' => 'textarea',
'name' => 'content',
'caption' => '',
'colspan' => true
),
'submit' => array(
'type' => 'submit',
'name' => 'submit',
'value' => _t('_wall_post'),
'colspan' => true
)
),
);
I wanted to edit HTML file first, but the only HTML code for this is:
<!-- Post Text -->
<div class="wall-ptype-cnt wall_text">__post_wall_text__</div>
Can someone please help me with editing array to allow file attachment?
Thank you.
You should try something like this:
function _getWriteForm()
{
$aForm = array(
'form_attrs' => array(
'name' => 'WallPostText',
'action' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'post/',
'method' => 'post',
'enctype' => 'multipart/form-data',
'target' => 'WallPostIframe',
'onsubmit' => 'javascript:return ' . $this->_sJsPostObject . '.postSubmit(this);'
),
'inputs' => array(
'content' => array(
'type' => 'textarea',
'name' => 'content',
'caption' => '',
'colspan' => true
),
'file' => array(
'type' => 'file',
'name' => 'upload_file',
'caption' => 'Upload',
'colspan' => true
),
'file_two' => array( //I added a second input file
'type' => 'file',
'name' => 'upload_file_two',
'caption' => 'Upload',
'colspan' => true
),
'submit' => array(
'type' => 'submit',
'name' => 'submit',
'value' => _t('_wall_post'),
'colspan' => true
)
),
);
I hope it helps.
Saludos ;)