Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with remove node: Undefined variable: keyAttribute #185

Closed
neelamharne21 opened this issue Feb 14, 2018 · 3 comments
Closed

Problem with remove node: Undefined variable: keyAttribute #185

neelamharne21 opened this issue Feb 14, 2018 · 3 comments
Labels

Comments

@neelamharne21
Copy link

neelamharne21 commented Feb 14, 2018

when i try to delete node it shows error msg : Undefined variable: keyAttribute

@strtob
Copy link

strtob commented May 7, 2018

what was the problem?

@moltam
Copy link

moltam commented Jun 27, 2018

@strtob The problem for me was that the model generated by Gii overwrited the rules() method. Just remove the rules() method from your generated model, and leave the validation for the extension.

If you generate the model, the following rules are generated:

public function rules()
{
    return [
        [['root', 'lft', 'rgt', 'lvl', 'icon_type', 'active', 'selected', 'disabled', 'readonly', 'visible', 'collapsed', 'movable_u', 'movable_d', 'movable_l', 'movable_r', 'removable', 'removable_all'], 'integer'],
        [['name'], 'required'],
        [['name'], 'string', 'max' => 60],
        [['icon'], 'string', 'max' => 255],
    ];
}

The TreeTrait treats some of these integer fields as boolean (for example: $child->active = true;), and the validation will fail because of the integer rule. So removing the unnecessary rules() method from your model solves the problem.

@kartik-v I think there is indeed an undefined variable in the TreeTrait. There is an extract before this (extract($module->treeStructure);), but the keyAttribute, and nameAttribute is declared in the $module->dataStructure array.

@kartik-v kartik-v added the bug label Jun 28, 2018
@kartik-v kartik-v reopened this Jun 28, 2018
@kartik-v
Copy link
Owner

This is resolved via the fix above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants