yiisoft / yii2-jui Goto Github PK
View Code? Open in Web Editor NEWYii 2 JQuery UI extension.
Home Page: http://www.yiiframework.com
License: BSD 3-Clause "New" or "Revised" License
Yii 2 JQuery UI extension.
Home Page: http://www.yiiframework.com
License: BSD 3-Clause "New" or "Revised" License
Moved from yiisoft/yii2#7955
When using the DatePickerLanguageAsset the timestamp for cache busting is not generated. See the following sample.
<script src="/assets/5e77cca1/yii.js?v=1427914473"></script>
<script src="/assets/5e77cca1/yii.validation.js?v=1427914473"></script>
<script src="/assets/cc5c2917/jquery-ui.js?v=1427915414"></script>
<script src="/assets/cc5c2917/ui/i18n/datepicker-de.js"></script>
<script src="/assets/5e77cca1/yii.activeForm.js?v=1427914473"></script>
<script src="/assets/b62c97e8/js/bootstrap.js?v=1427914473"></script>
Why not?
Hi
I need datepicker for yii2 gridview. So i choose jui. It was working perfect on the page reload. When i choose pjax, every time when the datepicker value changes my automatically reloads. Without the datepicker it was working my page not reloaded. Can you point me anything i did work?
For reference i put my code here:
`
Pjax::begin();
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'td_created_datetime',
'filter' => \yii\jui\DatePicker::widget([
'model' => $searchModel,
'attribute' => 'td_created_datetime',
'language' => 'en',
'dateFormat' => 'yyyy-MM-dd',
'clientEvents' => [
'change' => "function(e){
alert('occured');
e.preventDefault();
}"
],
]),
],
],
]);
Pjax::end();`
I have 2 different controller and in login model i want to switch to corret db in base at controller->id
class LoginModel extends \yii\db\ActiveRecord{
public static function getDb() {
if(Yii::$app->controller->id==="controller1"){
return Yii::$app->db1;
} else if(Yii::$app->controller->id==="controller2"){
return Yii::$app->db2;
}
}
}
Trying to get property of non-object
Yii::$app->controller = NULL
No exception and Yii::$app->controller->id = controller1
In yii2 version 2.0.7 the problem not exist.
Q | A |
---|---|
Yii vesion 2.0.15-dev | |
PHP version 5.5.17 | |
Operating system Windows Server 2008 R2 |
When I use DatePicker
on page, like as
<?= DatePicker::widget([
'model' => $context->model,
'attribute' => 'date',
'options' => [
'required' => 'true',
'placeholder' => 'Select date',
'class' => 'form-control',
],
]); ?>
In popup I get conflict, when use DatePicker
in form:
<?= $form->field($model, 'date')->widget(DatePicker::className(), [
'clientOptions' => [
'class' => 'form-control',
],
]) ?>`
Q | A |
---|---|
Yii vesion | 2.0.9 |
PHP version | 5.4.45 |
Operating system | Linux |
I'm fighting to format date in DatePicker. I like to set dateFormat in js manner without any transformation. so in my project I have subclassed datePiker and changed the run method from line 142:
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4));
} else {
$this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language);
}
to:
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4));
} else if (strncmp($this->dateFormat, 'js:', 3) === 0) {
$this->clientOptions['dateFormat'] = substr($this->dateFormat, 3);
} else {
$this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language);
}
I think that this can be usefoul and work very well.
Can you put this change in your code?
Q | A |
---|---|
Yii vesion | |
PHP version | |
Operating system |
Upgrade yii2 to 2.0.13, jquery updates 2->3
AutoComplete show value list in wrong position
Q | A |
---|---|
Yii vesion | 2.0.13 |
PHP version | 7 |
I want to bind two datepickers for choosing period. So, date of the first one should be lower than second one. I want to use datepicker's "onClose" option. But I can't find something looks like this in the manual of widget.
What the best way to add option "onClose" or maybe you know another method for choosing period with JQuery UI components?
SliderInput
provides a create
clientside event. But currently it's not possible to attach a handler there, because the inline code that attaches the event handler comes after the init code for the slider itself - which is too late:
<?= $form->field($model, 'minPrice')
->widget(SliderInput::className(), [
'clientOptions' => [
'min' => 0,
'max' => $priceLimit,
],
'clientEvents' => [
'create' => $sliderHandler,
],
]);
?>
Leads to this inline js code:
jQuery('#minPrice-container').slider({...});
jQuery('#minPrice-container').on('slidecreate', function(event, ui) { ... });
So the clientEvents
should be attached first, then the widget should be initialized.
composer diagnose
Checking composer.json: WARNING
require.yiisoft/yii2 : unbound version constraints (>=2.0.4) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
$ composer require --prefer-dist yiisoft/yii2-jui
Your requirements could not be resolved to an installable set of packages.
Problem 1
- yiisoft/yii2-jui 2.0.6 requires bower-asset/jquery-ui 1.11.@stable -> no matching package found.
- yiisoft/yii2-jui 2.0.5 requires bower-asset/jquery-ui 1.11.@stable -> no matching package found.
- yiisoft/yii2-jui 2.0.4 requires bower-asset/jquery-ui 1.11.@stable -> no matching package found.
- yiisoft/yii2-jui 2.0.3 requires bower-asset/jquery-ui 1.11.@stable -> no matching package found.
- yiisoft/yii2-jui 2.0.2 requires bower-asset/jquery-ui 1.11.@stable -> no matching package found.
- yiisoft/yii2-jui 2.0.1 requires bower-asset/jquery-ui 1.11.@stable -> no matching package found.
- yiisoft/yii2-jui 2.0.0 requires bower-asset/jquery-ui 1.11.*@stable -> no matching package found.
- Installation request for yiisoft/yii2-jui ^2.0 -> satisfiable by yiisoft/yii2-jui[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6].
Potential causes:
Is/will it be possible to use Selectable widget with ActiveForm?
File: https://github.com/yiisoft/yii2-jui/blob/8195a03e1a0bf64fe1df20b8993b6c7bad0e1b10/src/DatePicker.php
Issue: L177-182
If you configure the widget incorrectly by setting an invalid dateFormat
value, the widget will behave as commented on L181: "// ignore exception and keep original value if it is not a valid date".
If you make an error in the widget configuration, you should be notified about that error, because it's a bug.
Current behavior catches the exception and then ignores it as if it was not a problem. There should only be a fallback to defaults when the dateFormat
property was not included in the configuration array at all.
$model->addError('date', 'test error');
echo $form->field($model, 'date')->widget(DatePicker::class);
Input with datepicker and error text
Input with datepicker with no error
How to fix it?
After this update, the up/down buttons of the Spinner widget will be unvisible. The buttons are there and they work, but they're just not visible.
To reproduce, just have a page with a Spinner widget on it, and upgrade yii2-jui to version 2.0.7.
The issue is the result of a subtle conflict between jquery-ui.js 1.12.x and bootstrap.js. It is explained in detail here.
As a workaround, make JuiAsset load version 1.11.4 of jquery-ui in stead of version 1.12.1 (for instance via the assetManager app-component).
Yii version 2.0.13
PHP version 7.1.7
Windows 10
(but it will apply to other versions as well)
datepicker is configed as follow
'clientEvents' => [
'change' => 'function () { alert('event "change" occured.'); }'
],
it doesnt work.
i find the 96 line code in the file yii2-jui\widget.php
if (isset($this->clientEventMap[$event])) {
$eventName = $this->clientEventMap[$event];
} else {
$eventName = strtolower($name . $event);
}
will produce the js like the following:
jQuery('#w1').on('datepickerchange', function () {....}
the event datepickerchange dose not exist.
change 96 line code to
$eventName = strtolower($event);
will work.
is this a bug or any other use ?
I cannot install to yii 2.0.5
In some cases (see example below) DatePicker transforms invalid user input into invalid date. Instead exact invalid user input must remain in the field.
Example:
Yii::$app->formatter->dateFormat
is set to 'php:Y-m-d'
Date validator is set as:
['someDate', 'date']
DatePicker is rendered as:
<?= $form->field($model, 'someDate')->widget(DatePicker::className()) ?>
When user enters value '1234567' into DatePicker input field and submits the form that input field incorrectly displays '1970-01-15' instead of original user input '1234567'. This happens because the following code tries to format value '1234567' using Yii::$app->formatter->asDate()
which in turn tries to parse its first argument as UNIX timestamp value:
protected function renderWidget()
{
// ..........
if ($value !== null && $value !== '') {
// format value according to dateFormat
try {
$value = Yii::$app->formatter->asDate($value, $this->dateFormat);
} catch(InvalidParamException $e) {
// ignore exception and keep original value if it is not a valid date
}
}
Don't know how to work around that problem and I think to fix it a significant redesign of DatePicker will be needed.
Q | A |
---|---|
Yii vesion | |
PHP version | |
Operating system |
Attached clientEvents
to Droppable widget like this:
"clientEvents" => [ "drop" => "function (event, ui) { alert(ui); }" ]
Expected an alert when the item is dropped at the area.
No alert popped.
jQuery added inline at the end of the page uses another set of event names:
Query('#omitted_services').on('droppabledrop', function (event, ui) { alert(ui); });
Same thing happens with Draggable events.
Q | A |
---|---|
Yii vesion | 2.0.9 |
PHP version | 7.0.7 |
Operating system | Ubuntu |
Is jui Have altFormat ?
Set $app->language = 'en-US'
, use DatePickerWidget anywhere in page.
If language JS file doesn't exist, it shouldn't be included.
404 not found error in javascript console of the browser.
Q | A |
---|---|
Yii vesion | 2.0.13.1 |
PHP version | 7.1.4 |
Operating system | macOS Sierra |
My Code:
\yii\jui\AutoComplete::widget([ 'id' => 'player_search_input', 'clientOptions' => [ 'minLength' => 3, 'source' => "function(request, response){console.log('asd');}" ] ]);
Page Source Code:
jQuery('#player_search_input').autocomplete({"minLength":3,"source":"function(request, response){console.log(\u0027asd\u0027);}"});
As you can see: console.log(\u0027asd\u0027); - not need))
So. How I'm can disable qoutting there?
SamDark, Как это безобразие выключить то? Я ж хочу сырой код получить, без обработчиков
С дубляжом на русский)
The links for the attributes, methods and classes are not pointed correctly.
This issue has originally been reported by @i-skiba at yiisoft/yii2#13505.
Moved here by @cebe.
Now Dialog requires bootstrap.js because in init method
namespace yii\jui;
class Dialog extends Widget
{
....
public function init()
{
parent::init();
echo Html::beginTag('div', $this->options) . "\n";
//Fix for closing icon (x) not showing up in dialog
$this->getView()->registerJs("
var bootstrapButton = $.fn.button.noConflict();
$.fn.bootstrapBtn = bootstrapButton;",
\yii\web\View::POS_READY
);
}
.....
}
after update to 2.0.11 our project throws javascript exception
is not function a $.fn.button.noConflict()
But we dont use bootstrap in our project
Please, back clear init without any js
Q | A |
---|---|
Yii version | 2.0.11 |
PHP version | 5.6 |
Operating system | Debian |
Does the yii3.0 version give up this repo?
This issue has originally been reported by @mtangoo at yiisoft/yii2#5471.
Moved here by @klimov-paul.
The problem seems to be with Jquery and there is a workaround mentioned here
and here I quote it:
"The reason this is happening, is because you are calling bootstrap in, after you are calling jquery-ui in. Literally, swap the two so that instead of:
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="/js/bootstrap.min.js"></script>
it becomes
<script src="js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
"
New feature to allow to make selectable any item, between the begin() and end() widget calls, matching the filter attribute value selector.
Uses:
Selectable::begin([
'clientOptions' => [
'filter' => 'my-selectable-item'
'tolerance' => 'fit',
],
]);
<ul>
<li class="my-selectable-item">Item 1</li>
<li class="my-selectable-item">Item 2</li>
<li class="no-selectable-item">Item 3</li>
<li class="my-selectable-item">Item 4</li>
</ul>
<div>
<div>
<div class="my-selectable-item">Another item </div>
</div>
</div>
Selectable::end();
Currently uses draggable{event_name} for event names. And documentation says different http://api.jqueryui.com/draggable/#events
Solution: add
protected $clientEventMap = [
'create' => 'dragcreate',
'drag' => 'drag',
'stop' => 'dragstop',
'start' => 'dragstart',
];
With simple config
// config:
'formatter' => [
'class' => 'yii\i18n\Formatter',
// 'dateFormat' => 'php:d-M-Y',
'dateFormat' => 'dd.MM.yyyy',
],
// model rules():
['published_at', 'date', 'timestampAttribute' => 'published_at'],
// widget:
$form->field($model, 'published_at')->widget(DatePicker::className(), [
'options' => ['class' => 'form-control'],
])
everything works ok, but if 'dateFormat' of formatter will be changed to, for example 'php:d-M-Y' datePicker widget starts handle different with DateValidator formatting, so posted value will never pass validation.
if alternately set up 'format' for model rule and same format as 'dataFormat' for DatePicker widget to avoid using global formatter values, anyways it will handle format 'php:d-M-Y' incorrectly. Client script looks like:
$('#post-published_at').datepicker($.extend({}, $.datepicker.regional['ru'], {"dateFormat":"dd-M-yy"}));
and when form with existent data loads, then data shown (for russian locale) as "19-мая-2016" but when I changed date - it shown as "18-Май-2016". so it has different form of nouns for month and obviously format is not same.
I am not sure it is real bug, but looks like some date format won't be handled correctly as described.
component | version |
---|---|
Yii vesion | 2.0.8 |
PHP version | 7.0.4 |
Operating system | Ubuntu xenial |
It would be great if we could use the SliderInput
widget like this:
// Model attribute
public $priceRange = [0, 1000];
// Form:
$form->field($model, 'priceRange')
->widget(SliderInput::className(), [
'clientOptions' => [
'range' => true,
'min' => 0,
'max' => 1000,
],
]);
With the current implementation this gives an "Array to string conversion" exception.
When I'm using the Tabs widget, I'm able to specify a css class by using: options, itemOptions,
headerOptions and clientOptions properties but none of these set a class to the ul tag.
echo Tabs::widget([ 'items' => [ [ 'label' => 'Tab one', 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...', ], ], 'options' => ['tag' => 'div','class' => 'class_a'], #Applied on DIV tag 'itemOptions' => ['tag' => 'div','class' => 'class_b'], #Applied on DIV tag (content for each LI tag) 'headerOptions' => ['class' => 'class_c'], #Applied on LI tag 'clientOptions' => ['collapsible' => false], 'class' => 'CUSTOM_UL_CLASS' #This would allow me to set a custom UL class ]);
Is there a way to set a custom class in the UL tag? otherwise could you include this option on your code?
Composer dependency of JUI require
"bower-asset/jquery-ui": "1.11.*@stable"
while current jQueryUI stable version is 1.12.1
I want to use 'classes' option of Widget Factory, but it's available only in 1.12+ versions of jQueryUI.
Composer can't update JUI to this version now. Do I really have to install this version manually?
Spinner ' button disappeared.
Q | A |
---|---|
Yii vesion | 2.0.13.1 |
PHP version | 7.1 |
Operating system | CentOS 7 |
That's what I have tried:
Note that I put maxDate inside both clientOptions and options because I don't know where I should place it. Anyways, it didn't work.
How can I do it?
How to create custom display items ?
This issue has originally been reported by @hirenbhut93 at yiisoft/yii2#12742.
Moved here by @samdark.
I used CDN api for jquery-ui.min.js
& jquery-ui.min.css
like
'bundles' => [
'yii\jui\JuiAsset' => [
'css' => [
YII_ENV_DEV ? 'themes/smoothness/jquery-ui.css' : '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.min.css',
],
'js' => [
YII_ENV_DEV ? 'jquery-ui.js' : '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js',
],
],
],
I have used yii\jui\DatePicker
in my bootstrap modal like.
<?= $form->field($user, 'dob')->widget(DatePicker::className(), [
'clientOptions' => [
'changeMonth' => true,
'changeYear' => true,
],
'options' => [
'class' => 'form-control',
'readOnly' => true,
],
]) ?>
I use renderAjax
in my controller action.
However display error message TypeError: jQuery(...).datepicker is not a function
.
When i disabled/remove CDN of JuiAsset
work perfectly.
I have many try to resolved this issue but not find any solution.
Why?
Q | A |
---|---|
Yii version | 2.0.9 |
PHP version | 5.6 |
Operating system | UBUNTU |
In yii\jui\DatePicker::run
:
https://github.com/yiisoft/yii2-jui/blob/master/DatePicker.php#L142
...
if (strncmp($this->dateFormat, 'php:', 4) === 0) {
$this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4), 'date', $language);
} else {
...
But in \yii\helpers\BaseFormatConverter::convertDatePhpToJui
https://github.com/yiisoft/yii2/blob/master/framework/helpers/BaseFormatConverter.php#L460
...
* @param string $pattern date format pattern in php date()-function format.
* @return string The converted date format pattern.
*/
public static function convertDatePhpToJui($pattern)
{
...
Uncaught RangeError: Maximum call stack size exceeded
Q | A |
---|---|
Yii 2 | |
PHP version 7 |
This issue has originally been reported by @midcore-nam at yiisoft/yii2#11916.
Moved here by @samdark.
jui draggable events doesn't start.
events should start.
event doesn't start.
i found out that jqueryui had changed their event name. it is 'drag' instead of 'draggable'.
Q | A |
---|---|
Yii version | 2.0.8 |
PHP version | 7 |
Operating system | win 10 |
$("#qqq").dialog("open")
opens a dialog
f.getClientRects is not a function
Q | A |
---|---|
Yii vesion | 2.0.13 |
PHP version | 7.1 |
Operating system | debian 8 |
This issue has originally been reported by @tom-- at yiisoft/yii2#9312.
Moved here by @cebe.
I noticed the following differences when using jQuery-UI Datepicker. Formatter
was providing the date input's initial value on page load and the format changed after using Datepicker.
Both are ICU 'medium'.
locale | asDate() | convertDateIcuToJui() |
---|---|---|
en-US | Apr 4, 2015 | Apr 4 2015 |
ru-RU | 04 авг. 2015 г. | 04 Авг 2015 г. |
or something like that
How would I add a bootstrap class to input
<?= $form->field( $model, 'birthday' )->widget( \yii\jui\DatePicker::classname(), [ 'language' => 'ru', 'dateFormat' => 'yyyy-MM-dd', 'class' => 'form-control',] ) ?>
This method does not work. Thank you
I have 2 installs with jquery-ui. My development box has vendor/bower/jquery-ui - it works fine.
My test box has vendor/bower-asset/jquery-ui and this does not work, I get:
Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: _________/app/vendor/bower/jquery-ui
I have completely reinstalled vendor directories with "composer install" and the exact same composer.json & composer.lock files on both systems & they still reinstall to bower and bower-asset, respectively, I'm not a composer expert and don't really want to spend the time to figure out why they are different.
But this should work no matter where it is installed, all the standard jquery stuff does.
The work around is simple:
cd vendor
ln -s bower-asset bower
i want to customized datepicker via my own classes how should i add my own class via configuration?
I works on multi language application arabic and english
the problem that when i want to edit a date while i am open the backend as arabic language the date shows as arabic numbers and if i save the form the data will saved as arabic numbers to my database.
Edit date form :
<?= $form->field($model, 'match_date')->widget(\yii\jui\DatePicker::classname(),[
'language' => Yii::$app->language,
'dateFormat' => 'yyyy-MM-dd',
'options' => ['class' => 'form-control']
]) ?>
On my frontend application i install php intl and yii2 formatter works good for me but the arabic date will show an error and the page failed to load because the arabic numbers
I think DatePicker must always saved date as english
| Yii vesion | 2.0.6
| PHP version | 7
| Operating system | ubuntu
Hey,
DatePicker sets an empty field for value == NULL
. However many real world cases will have database entries of empty strings (''
) for columns with no dates. Having these fields default to 01/01/1970 is an issue.
Maybe this has already been discussed but I think the DatePicker widget should be less restrictive and check for value == NULL || value == ''
. If a user really wanted 01/01/1970 they could set their db default as 0
or "0"
I'm saying this because some databases will not allow you to NULL
a db field set as String
or Int
. But in the absolutely rare event that you actually did want to display the date of 01/01/1970 0
would still be an option.
I will most likely make a pull request since I think it'll be an easy fix. Feel free to ignore/reject it if I'm missing something crucial
Is it possible using yii2-jui?
Here is my code to create a sortable widget in a table
echo Sortable::widget([
'items' => [
['content' => '<td width="100">Item 1</td>'],
['content' => '<td width="100">Item 2</td>'],
['content' => '<td width="100">Item 3</td>'],
['content' => '<td width="100">Item 4</td>'],
],
'options' => ['tag' => 'table'],
'itemOptions' => ['tag' => 'tr', 'style' => 'cursor:pointer'],
]);
But the result is class ui-sortable-handle
will be placed inside tbody
, not tr
. So I came up with this code
echo '<table class="table table-hover table-striped">';
echo Sortable::widget([
'items' => [
['content' => '<td width="100">Item 1</td>'],
['content' => '<td width="100">Item 2</td>'],
['content' => '<td width="100">Item 3</td>'],
['content' => '<td width="100">Item 4</td>'],
],
'options' => ['tag' => 'tbody'],
'itemOptions' => ['tag' => 'tr', 'style' => 'cursor:pointer'],
]);
echo "</table>";
What is the proper way other than making my own sub-widget?
Q | A |
---|---|
Yii version | 2.0.9 |
PHP version | 5.5 |
Operating system | OS X 10.10 |
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.