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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
4ad022c3
Commit
4ad022c3
authored
Sep 05, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #3240: Added support for assigning an anonymous function to…
Fixes #3240: Added support for assigning an anonymous function to `yii\widgets\ActiveForm::fieldConfig`
parent
e15cfc02
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
12 deletions
+32
-12
ActiveForm.php
extensions/bootstrap/ActiveForm.php
+5
-3
FixtureController.php
extensions/faker/FixtureController.php
+4
-4
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
ActiveForm.php
framework/widgets/ActiveForm.php
+22
-5
No files found.
extensions/bootstrap/ActiveForm.php
View file @
4ad022c3
...
...
@@ -66,6 +66,11 @@ use yii\base\InvalidConfigException;
class
ActiveForm
extends
\yii\widgets\ActiveForm
{
/**
* @var string the default field class name when calling [[field()]] to create a new field.
* @see fieldConfig
*/
public
$fieldClass
=
'yii\bootstrap\ActiveField'
;
/**
* @var array HTML attributes for the form tag. Default is `['role' => 'form']`.
*/
public
$options
=
[
'role'
=>
'form'
];
...
...
@@ -91,9 +96,6 @@ class ActiveForm extends \yii\widgets\ActiveForm
if
(
$this
->
layout
!==
'default'
)
{
Html
::
addCssClass
(
$this
->
options
,
'form-'
.
$this
->
layout
);
}
if
(
!
isset
(
$this
->
fieldConfig
[
'class'
]))
{
$this
->
fieldConfig
[
'class'
]
=
ActiveField
::
className
();
}
parent
::
init
();
}
}
extensions/faker/FixtureController.php
View file @
4ad022c3
...
...
@@ -338,7 +338,7 @@ class FixtureController extends \yii\console\controllers\FixtureController
}
/**
* Returns array containg fixtures templates file names. You can specify what files to find
* Returns array contain
in
g fixtures templates file names. You can specify what files to find
* by the given parameter.
* @param array $templatesNames template file names to search. If empty then all files will be searched.
* @return array
...
...
@@ -428,9 +428,9 @@ class FixtureController extends \yii\console\controllers\FixtureController
/**
* Generates fixture file by the given fixture template file.
* @param
type
$templateName template file name
* @param
type
$templatePath path where templates are stored
* @param
type
$fixtureDataPath fixture data path where generated file should be written
* @param
string
$templateName template file name
* @param
string
$templatePath path where templates are stored
* @param
string
$fixtureDataPath fixture data path where generated file should be written
*/
public
function
generateFixtureFile
(
$templateName
,
$templatePath
,
$fixtureDataPath
)
{
...
...
framework/CHANGELOG.md
View file @
4ad022c3
...
...
@@ -121,6 +121,7 @@ Yii Framework 2 Change Log
-
Enh #3222: Added
`useTablePrefix`
option to the model generator for Gii (horizons2)
-
Enh #3230: Added
`yii\filters\AccessControl::user`
to support access control with different actors (qiangxue)
-
Enh #3232: Added
`export()`
and
`exportAsString()`
methods to
`yii\helpers\BaseVarDumper`
(klimov-paul)
-
Enh #3240: Added support for assigning an anonymous function to
`yii\widgets\ActiveForm::fieldConfig`
(qiangxue)
-
Enh #3244: Allow logging complex data such as arrays and object via the log system (cebe)
-
Enh #3252: Added support for case insensitive matching using ILIKE to PostgreSQL QueryBuilder (cebe)
-
Enh #3280: Support dynamically attaching anonymous behaviors (qiangxue)
...
...
framework/widgets/ActiveForm.php
View file @
4ad022c3
...
...
@@ -51,7 +51,20 @@ class ActiveForm extends Widget
*/
public
$options
=
[];
/**
* @var array the default configuration used by [[field()]] when creating a new field object.
* @var string the default field class name when calling [[field()]] to create a new field.
* @see fieldConfig
*/
public
$fieldClass
=
'yii\widgets\ActiveField'
;
/**
* @var array|\Closure the default configuration used by [[field()]] when creating a new field object.
* This can be either a configuration array or an anonymous function returning a configuration array.
* If the latter, the signature should be as follows,
*
* ```php
* function ($model, $attribute)
* ```
*
* @see fieldClass
*/
public
$fieldConfig
;
/**
...
...
@@ -223,9 +236,6 @@ class ActiveForm extends Widget
if
(
!
isset
(
$this
->
options
[
'id'
]))
{
$this
->
options
[
'id'
]
=
$this
->
getId
();
}
if
(
!
isset
(
$this
->
fieldConfig
[
'class'
]))
{
$this
->
fieldConfig
[
'class'
]
=
ActiveField
::
className
();
}
echo
Html
::
beginForm
(
$this
->
action
,
$this
->
method
,
$this
->
options
);
}
...
...
@@ -313,7 +323,14 @@ class ActiveForm extends Widget
*/
public
function
field
(
$model
,
$attribute
,
$options
=
[])
{
return
Yii
::
createObject
(
array_merge
(
$this
->
fieldConfig
,
$options
,
[
$config
=
$this
->
fieldConfig
;
if
(
$config
instanceof
\Closure
)
{
$config
=
call_user_func
(
$config
,
$model
,
$attribute
);
}
if
(
!
isset
(
$config
[
'class'
]))
{
$config
[
'class'
]
=
$this
->
fieldClass
;
}
return
Yii
::
createObject
(
array_merge
(
$config
,
$options
,
[
'model'
=>
$model
,
'attribute'
=>
$attribute
,
'form'
=>
$this
,
...
...
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