Skip to content

Commit

Permalink
Collection unsed variabled deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed May 8, 2015
1 parent 1a909ad commit 23c808d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,9 @@ public function load ($data = null) {
$finalData = [];

if ($data === null) {
$data = \Yii::$app->request->post($this->formName) ?: [\Yii::$app->request->post()];

/*
* If all keys are not empty and are strings - then wrap with an empty array to normalize to
* ModelName[][attribute]
*/
if (array_sum(array_map(function ($key) { return !empty($key) && is_string($key); }, array_keys($data))) > 0) {
$data = [$data];
$data = \Yii::$app->request->post();
if (isset($data[$this->formName])) {
$data = $data[$this->formName];
}
} elseif ($data instanceof \Closure) {
$data = call_user_func($data, $this->model, $this->formName);
Expand Down Expand Up @@ -296,7 +291,7 @@ public function update ($runValidation = true, $attributes = null, $options = []

$results = $this->first->getDb()->createCommand()->perform($command, $data);

if ($result === false || Err::isError($result)) {
if ($results === false || Err::isError($results)) {
throw new HiResException(Err::getError($results), Json::encode($results));
}

Expand Down Expand Up @@ -355,7 +350,6 @@ public function collectData ($attributes = null, $options = []) {
* @return bool
*/
public function hasErrors () {
$hasErrors = false;
foreach ($this->models as $model) {
/* @var $model ActiveRecord */
if ($model->hasErrors()) {
Expand Down

0 comments on commit 23c808d

Please sign in to comment.