Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
0ff8518c
Commit
0ff8518c
authored
Dec 21, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1550: fixed the issue that JUI input widgets did not property input IDs.
parent
a126419e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
69 additions
and
39 deletions
+69
-39
CHANGELOG.md
extensions/yii/jui/CHANGELOG.md
+1
-1
DatePicker.php
extensions/yii/jui/DatePicker.php
+19
-4
InputWidget.php
extensions/yii/jui/InputWidget.php
+5
-1
SliderInput.php
extensions/yii/jui/SliderInput.php
+21
-9
Widget.php
extensions/yii/jui/Widget.php
+11
-7
CHANGELOG.md
framework/CHANGELOG.md
+3
-1
Captcha.php
framework/yii/captcha/Captcha.php
+0
-7
InputWidget.php
framework/yii/widgets/InputWidget.php
+9
-1
MaskedInput.php
framework/yii/widgets/MaskedInput.php
+0
-8
No files found.
extensions/yii/jui/CHANGELOG.md
View file @
0ff8518c
...
...
@@ -4,7 +4,7 @@ Yii Framework 2 jui extension Change Log
2.
0.0 beta under development
----------------------------
-
no changes in this release
.
-
Bug #1550: fixed the issue that JUI input widgets did not property input IDs
.
2.
0.0 alpha, December 1, 2013
-----------------------------
...
...
extensions/yii/jui/DatePicker.php
View file @
0ff8518c
...
...
@@ -54,14 +54,30 @@ class DatePicker extends InputWidget
* @var boolean If true, shows the widget as an inline calendar and the input as a hidden field.
*/
public
$inline
=
false
;
/**
* @var array the HTML attributes for the container tag. This is only used when [[inline]] is true.
*/
public
$containerOptions
=
[];
/**
* @inheritdoc
*/
public
function
init
()
{
parent
::
init
();
if
(
$this
->
inline
&&
!
isset
(
$this
->
containerOptions
[
'id'
]))
{
$this
->
containerOptions
[
'id'
]
=
$this
->
options
[
'id'
]
.
'-container'
;
}
}
/**
* Renders the widget.
*/
public
function
run
()
{
echo
$this
->
renderWidget
()
.
"
\n
"
;
$containerID
=
$this
->
inline
?
$this
->
containerOptions
[
'id'
]
:
$this
->
options
[
'id'
];
if
(
$this
->
language
!==
false
)
{
$view
=
$this
->
getView
();
DatePickerRegionalAsset
::
register
(
$view
);
...
...
@@ -71,10 +87,10 @@ class DatePicker extends InputWidget
$options
=
$this
->
clientOptions
;
$this
->
clientOptions
=
false
;
// the datepicker js widget is already registered
$this
->
registerWidget
(
'datepicker'
,
DatePickerAsset
::
className
());
$this
->
registerWidget
(
'datepicker'
,
DatePickerAsset
::
className
()
,
$containerID
);
$this
->
clientOptions
=
$options
;
}
else
{
$this
->
registerWidget
(
'datepicker'
,
DatePickerAsset
::
className
());
$this
->
registerWidget
(
'datepicker'
,
DatePickerAsset
::
className
()
,
$containerID
);
}
}
...
...
@@ -101,8 +117,7 @@ class DatePicker extends InputWidget
$this
->
clientOptions
[
'defaultDate'
]
=
$this
->
value
;
}
$this
->
clientOptions
[
'altField'
]
=
'#'
.
$this
->
options
[
'id'
];
$this
->
options
[
'id'
]
.=
'-container'
;
$contents
[]
=
Html
::
tag
(
'div'
,
null
,
$this
->
options
);
$contents
[]
=
Html
::
tag
(
'div'
,
null
,
$this
->
containerOptions
);
}
return
implode
(
"
\n
"
,
$contents
);
...
...
extensions/yii/jui/InputWidget.php
View file @
0ff8518c
...
...
@@ -10,6 +10,7 @@ namespace yii\jui;
use
Yii
;
use
yii\base\Model
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\Html
;
/**
* InputWidget is the base class for all jQuery UI input widgets.
...
...
@@ -44,7 +45,10 @@ class InputWidget extends Widget
public
function
init
()
{
if
(
!
$this
->
hasModel
()
&&
$this
->
name
===
null
)
{
throw
new
InvalidConfigException
(
"Either 'name' or 'model' and 'attribute' properties must be specified."
);
throw
new
InvalidConfigException
(
"Either 'name', or 'model' and 'attribute' properties must be specified."
);
}
if
(
$this
->
hasModel
()
&&
!
isset
(
$this
->
options
[
'id'
]))
{
$this
->
options
[
'id'
]
=
Html
::
getInputId
(
$this
->
model
,
$this
->
attribute
);
}
parent
::
init
();
}
...
...
extensions/yii/jui/SliderInput.php
View file @
0ff8518c
...
...
@@ -50,30 +50,42 @@ class SliderInput extends InputWidget
'start'
=>
'slidestart'
,
'stop'
=>
'slidestop'
,
];
/**
* @var array the HTML attributes for the container tag.
*/
public
$containerOptions
=
[];
/**
* @inheritdoc
*/
public
function
init
()
{
parent
::
init
();
if
(
!
isset
(
$this
->
containerOptions
[
'id'
]))
{
$this
->
containerOptions
[
'id'
]
=
$this
->
options
[
'id'
]
.
'-container'
;
}
}
/**
* Executes the widget.
*/
public
function
run
()
{
echo
Html
::
tag
(
'div'
,
''
,
$this
->
o
ptions
);
echo
Html
::
tag
(
'div'
,
''
,
$this
->
containerO
ptions
);
$inputId
=
$this
->
id
.
'-input'
;
$inputOptions
=
$this
->
options
;
$inputOptions
[
'id'
]
=
$inputId
;
if
(
$this
->
hasModel
())
{
echo
Html
::
activeHiddenInput
(
$this
->
model
,
$this
->
attribute
,
$
inputO
ptions
);
echo
Html
::
activeHiddenInput
(
$this
->
model
,
$this
->
attribute
,
$
this
->
o
ptions
);
}
else
{
echo
Html
::
hiddenInput
(
$this
->
name
,
$this
->
value
,
$
inputO
ptions
);
echo
Html
::
hiddenInput
(
$this
->
name
,
$this
->
value
,
$
this
->
o
ptions
);
}
if
(
!
isset
(
$this
->
clientEvents
[
'slide'
]))
{
$this
->
clientEvents
[
'slide'
]
=
'function(event, ui) {
$("#'
.
$inputId
.
'").val(ui.value);
$("#'
.
$this
->
options
[
'id'
]
.
'").val(ui.value);
}'
;
}
$this
->
registerWidget
(
'slider'
,
SliderAsset
::
className
());
$this
->
getView
()
->
registerJs
(
'$("#'
.
$inputId
.
'").val($("#'
.
$this
->
id
.
'").slider("value"));'
);
$this
->
registerWidget
(
'slider'
,
SliderAsset
::
className
()
,
$this
->
containerOptions
[
'id'
]
);
$this
->
getView
()
->
registerJs
(
'$("#'
.
$this
->
options
[
'id'
]
.
'").val($("#'
.
$this
->
id
.
'").slider("value"));'
);
}
}
extensions/yii/jui/Widget.php
View file @
0ff8518c
...
...
@@ -76,11 +76,11 @@ class Widget extends \yii\base\Widget
/**
* Registers a specific jQuery UI widget options
* @param string $name the name of the jQuery UI widget
* @param string $id the ID of the widget
*/
protected
function
registerClientOptions
(
$name
)
protected
function
registerClientOptions
(
$name
,
$id
)
{
if
(
$this
->
clientOptions
!==
false
)
{
$id
=
$this
->
options
[
'id'
];
$options
=
empty
(
$this
->
clientOptions
)
?
''
:
Json
::
encode
(
$this
->
clientOptions
);
$js
=
"jQuery('#
$id
').
$name
(
$options
);"
;
$this
->
getView
()
->
registerJs
(
$js
);
...
...
@@ -90,11 +90,11 @@ class Widget extends \yii\base\Widget
/**
* Registers a specific jQuery UI widget events
* @param string $name the name of the jQuery UI widget
* @param string $id the ID of the widget
*/
protected
function
registerClientEvents
(
$name
)
protected
function
registerClientEvents
(
$name
,
$id
)
{
if
(
!
empty
(
$this
->
clientEvents
))
{
$id
=
$this
->
options
[
'id'
];
$js
=
[];
foreach
(
$this
->
clientEvents
as
$event
=>
$handler
)
{
if
(
isset
(
$this
->
clientEventMap
[
$event
]))
{
...
...
@@ -112,11 +112,15 @@ class Widget extends \yii\base\Widget
* Registers a specific jQuery UI widget asset bundle, initializes it with client options and registers related events
* @param string $name the name of the jQuery UI widget
* @param string $assetBundle the asset bundle for the widget
* @param string $id the ID of the widget. If null, it will use the `id` value of [[options]].
*/
protected
function
registerWidget
(
$name
,
$assetBundle
)
protected
function
registerWidget
(
$name
,
$assetBundle
,
$id
=
null
)
{
if
(
$id
===
null
)
{
$id
=
$this
->
options
[
'id'
];
}
$this
->
registerAssets
(
$assetBundle
);
$this
->
registerClientOptions
(
$name
);
$this
->
registerClientEvents
(
$name
);
$this
->
registerClientOptions
(
$name
,
$id
);
$this
->
registerClientEvents
(
$name
,
$id
);
}
}
framework/CHANGELOG.md
View file @
0ff8518c
...
...
@@ -9,6 +9,7 @@ Yii Framework 2 Change Log
-
Bug #1500: Log messages exported to files are not separated by newlines (omnilight, qiangxue)
-
Bug #1509: The SQL for creating Postgres RBAC tables is incorrect (qiangxue)
-
Bug #1545: It was not possible to execute db Query twice, params where missing (cebe)
-
Bug #1550: fixed the issue that JUI input widgets did not property input IDs.
-
Bug #1591: StringValidator is accessing undefined property (qiangxue)
-
Bug: Fixed
`Call to a member function registerAssetFiles() on a non-object`
in case of wrong
`sourcePath`
for an asset bundle (samdark)
-
Bug: Fixed incorrect event name for
`yii\jui\Spinner`
(samdark)
...
...
@@ -24,7 +25,8 @@ Yii Framework 2 Change Log
-
Enh: Added
`Widget::autoIdPrefix`
to support prefixing automatically generated widget IDs (qiangxue)
-
Enh: Support for file aliases in console command 'message' (omnilight)
-
Enh: Sort and Paginiation can now create absolute URLs (cebe)
-
Chg: Renamed yii
\j
ui
\W
idget::clientEventsMap to clientEventMap (qiangxue)
-
Chg: Renamed
`yii\jui\Widget::clientEventsMap`
to
`clientEventMap`
(qiangxue)
-
Chg: Added
`yii\widgets\InputWidget::options`
(qiangxue)
-
New #1438:
[
MongoDB integration
](
https://github.com/yiisoft/yii2-mongodb
)
ActiveRecord and Query (klimov-paul)
-
New #1393:
[
Codeception testing framework integration
](
https://github.com/yiisoft/yii2-codeception
)
(
Ragazzo
)
...
...
framework/yii/captcha/Captcha.php
View file @
0ff8518c
...
...
@@ -39,10 +39,6 @@ class Captcha extends InputWidget
*/
public
$captchaAction
=
'site/captcha'
;
/**
* @var array HTML attributes to be applied to the text input field.
*/
public
$options
=
[];
/**
* @var array HTML attributes to be applied to the CAPTCHA image tag.
*/
public
$imageOptions
=
[];
...
...
@@ -62,9 +58,6 @@ class Captcha extends InputWidget
$this
->
checkRequirements
();
if
(
!
isset
(
$this
->
options
[
'id'
]))
{
$this
->
options
[
'id'
]
=
$this
->
hasModel
()
?
Html
::
getInputId
(
$this
->
model
,
$this
->
attribute
)
:
$this
->
getId
();
}
if
(
!
isset
(
$this
->
imageOptions
[
'id'
]))
{
$this
->
imageOptions
[
'id'
]
=
$this
->
options
[
'id'
]
.
'-image'
;
}
...
...
framework/yii/widgets/InputWidget.php
View file @
0ff8518c
...
...
@@ -11,6 +11,7 @@ use Yii;
use
yii\base\Widget
;
use
yii\base\Model
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\Html
;
/**
* InputWidget is the base class for widgets that collect user inputs.
...
...
@@ -40,6 +41,10 @@ class InputWidget extends Widget
* @var string the input value.
*/
public
$value
;
/**
* @var array the HTML attributes for the input tag.
*/
public
$options
=
[];
/**
...
...
@@ -49,7 +54,10 @@ class InputWidget extends Widget
public
function
init
()
{
if
(
!
$this
->
hasModel
()
&&
$this
->
name
===
null
)
{
throw
new
InvalidConfigException
(
"Either 'name' or 'model' and 'attribute' properties must be specified."
);
throw
new
InvalidConfigException
(
"Either 'name', or 'model' and 'attribute' properties must be specified."
);
}
if
(
!
isset
(
$this
->
options
[
'id'
]))
{
$this
->
options
[
'id'
]
=
$this
->
hasModel
()
?
Html
::
getInputId
(
$this
->
model
,
$this
->
attribute
)
:
$this
->
getId
();
}
parent
::
init
();
}
...
...
framework/yii/widgets/MaskedInput.php
View file @
0ff8518c
...
...
@@ -61,10 +61,6 @@ class MaskedInput extends InputWidget
* @var string a JavaScript function callback that will be invoked when user finishes the input.
*/
public
$completed
;
/**
* @var array the HTML attributes for the input tag.
*/
public
$options
=
[];
/**
...
...
@@ -77,10 +73,6 @@ class MaskedInput extends InputWidget
if
(
empty
(
$this
->
mask
))
{
throw
new
InvalidConfigException
(
'The "mask" property must be set.'
);
}
if
(
!
isset
(
$this
->
options
[
'id'
]))
{
$this
->
options
[
'id'
]
=
$this
->
hasModel
()
?
Html
::
getInputId
(
$this
->
model
,
$this
->
attribute
)
:
$this
->
getId
();
}
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment