I am uploading multiple files in Yii with the help of CMultiFileUpload and this is the code:
$this->widget('CMultiFileUpload', array(
'model' => $model,
'attribute' => 'file',
'accept' => 'jpg|gif|png|pdf',
'options' => array(),
'denied' => 'File is not allowed',
'max' => 10
));
It worked in file upload but didn't show any data in edit form.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am creating a Prestashops 1.6 module. After added input in HelperForm select, then in html the script added class fixed-width-x1.
$fields_form[0]['form'] = array(
'tinymce' => true,
'legend' => array(
'title' => $this->l('Add rule'),
),
'submit' => array(
'name' => 'add',
'title' => $this->l('Add'),
'class' => 'btn btn-default pull-right'
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Category'),
'name' => 'category',
'required' => true
),
)
);
Screen Firebug
Why it works wrong?
I want add own class to select, but fixed-width-x1 override property width.
This class is automatically added by the HelperForm class in the proccess of rendering the select.
But, in my opinion, that you can do is add a class to the select and then change the style in this new class.
To add a new class to the select, only add this at the end of the options array:
'class' => 'name-of-custom-class'
Be sure that the comma after the last option exist.
In summary, should be like this:
$fields_form[0]['form'] = array(
'tinymce' => true,
'legend' => array(
'title' => $this->l('Add rule'),
),
'submit' => array(
'name' => 'add',
'title' => $this->l('Add'),
'class' => 'btn btn-default pull-right'
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Category'),
'name' => 'category',
'required' => true,
'class' => 'name-of-custom-class'
),
)
);
Hope it helps you.
[EDIT]
The HelperForm class uses a template to make this inputs. This template is:
/[admin-folder]/themes/default/template/helpers/form/form.tpl
In this file around the line 341, you can find this code:
{elseif $input.type == 'select'}
{if isset($input.options.query) && !$input.options.query && isset($input.empty_message)}
{$input.empty_message}
{$input.required = false}
{$input.desc = null}
{else}
<select name="{$input.name|escape:'html':'utf-8'}"
class="{if isset($input.class)}{$input.class|escape:'html':'utf-8'}{/if} fixed-width-xl"
In the last line you can see the place that is assigned this class with any control "fixed-width-xl".
The solution:
You can delete directly the class from the tpl, but this will affect
to all the inputs that are in the admin panel. And, in case of you want to update the prestashop version, is probably that you lost this change.
You can edit the admin css file deleting the "!important". This file is:
/[admin-folder]/themes/default/css/admin-theme.css
In my web application, I want to implement a date field. For this i am using CJuiDatePicker. But for me it not showing calendar.
My code is,
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'Employee[employee_joiningdate]',
'id' => 'Employee_employee_joiningdate',
'value' => Yii::app()->dateFormatter->format("d-M-y", strtotime($model->employee_joiningdate)),
'options' => array(`
'showAnim' => 'slide', //'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
'showOtherMonths' => true, // Show Other month in jquery
'selectOtherMonths' => true, // Select Other month in jquery
),
'htmlOptions' => array(
'class' => 'form-control'
),
));`
What i am doing wrong?
Please help me....
Thanks in advance.
thanks for reading, i am wondering how to install
YiiBooster
, do i need to install
YiiBootstrap
first ?
I want to install it by hand , is it enough to extract it to extensions folder and than configure the main.php or is there something i am missing ?
Also how can i make this point to the right path
'booster' => array(
'class' => 'path.alias.to.booster.components.Booster',
),
You don't need to install bootstrap. Yiibooster includes all bootstrap files it needs. Just download Yiibooster, unpack to the extension folder and add the below to your main config file,
'booster' => array(
'class' => 'ext.yiibooster.components.Bootstrap',
'responsiveCss' => true,
),
Then add the following in the preload section of the config,
'booster',
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
// preloading 'log' component
'preload'=>array('log','bootstrap'),
// application components
'components'=>array(
//
'bootstrap' => array(
'class' => 'bootstrap.components.Booster',
'responsiveCss' => true,
),
Rename folder name yiibooster-4.0.1 to yiibooster
Step 1:
'preload' => array(
'booster',
),
Step 2:
'booster' => array(
'class' => 'ext.yiibooster.components.Booster',
'responsiveCss' => true,
),
Note: Booster this Class name
//Use view file
<?php
$this->widget('booster.widgets.TbExtendedGridView',
array(
'filter' => $model,
'fixedHeader' => true,
'type' => 'striped bordered',
'headerOffset' => 40,
// 40px is the height of the main navigation at bootstrap
'dataProvider' =>$model->search(),
'template' => "{items}",
'columns' => array(
'id',
'firstname',
'lastname',
'age',
'address',
'email',
),
)
);
?>
I'm trying to use this extension in a partial view, in my registration module...
$form->widget('ext.tokenInput.TokenInput', array(
'model' => $model,
'attribute' => 'tags',
'url' => array('wizard/search'),
'options' => array(
'allowCreation' => false,
'preventDuplicates' => true,
'allowFreeTagging' => false,
'minChars' => 2,
'theme' => 'facebook',
)
));
...and assets (javascript and CSS files) are duplicated.
Basically I can see in the HTML code multiple occurrences of these files.
I have the same problem if I try to add custom JS files in the same partial view.
I specify POS_HEAD and I can see the code in <head> and in the middle of the page.
Why CClientScript duplicates assets if I add them in a partial view?
Thanks a lot!
Is there any way to hide "Summary" for CListView without loosing pagination. By summary i mean text like "Displaying 1-2 of 2 result(s).". Or maybe I should use different widget?
Try the following to get more control over the look of your CListView output:
'template'=>'{items} {pager}'
You can even use HTML in the template.
Ok, I didn't get it at first, when looking into CListView code, but setting 'summaryText' to '' will do the work. I've realised that second time when I was staring at $summaryText === null
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'summaryText'=>'',
'itemView'=>'_indexview',
));
Here is the example for CListView:
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $dataProvider,
'itemView' => '_view',
'ajaxUpdate' => false,
'emptyText' => 'No records found.',
'summaryText' => "{start} - {end} из {count}",
'template' => '{summary} {sorter} {items} {pager}',
'sorterHeader' => 'Sort by:',
'sortableAttributes' => array('title', 'price'),
'pager' => array(
'class' => 'CLinkPager',
'header' => false,
'cssFile' => '/css/pager.css',
'htmlOptions' => array('class' => 'pager'),
'maxButtonCount' => '10',
'prevPageLabel'=>'←',
'nextPageLabel'=>'→',
'header'=>'Pages: ',
),
));
You should try this:
'summaryText' => FALSE,
You may hide it by adding CSS in the page like below.
<style>
.summary{
display:none;
}
</style>
Here is my suggestion
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $best_seller_data,
'itemView' => 'alsoBestseller',
'summaryText'=>false,
));