Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

says shat wrond models and attribute #2

Open
hik200 opened this issue Sep 6, 2016 · 5 comments
Open

says shat wrond models and attribute #2

hik200 opened this issue Sep 6, 2016 · 5 comments
Labels

Comments

@hik200
Copy link

hik200 commented Sep 6, 2016

ERROR: Either 'models' and 'attribute' properties must be specified.
image

@bupy7
Copy link
Owner

bupy7 commented Sep 6, 2016

You need specify an array of models and not just a model.

@hik200
Copy link
Author

hik200 commented Sep 6, 2016

how? can give me example?

@bupy7
Copy link
Owner

bupy7 commented Sep 6, 2016

In your a controller:

public function actionIndex() 
{
    $models = ModelName::find()->all();
    if (Model::loadMultiple($models, Yii::$app->request->post()) && Model::validateMultiple($models)) {
        for ($i = 0; $i != count($models); $i++) {
            $models[$i]->save(false);
        }
        return $this->redirect(['index']);
    }
    return $this->render('index', ['models' => $models]); 
}

In your a view:

echo DynaFields::widget([
    'urlAdd' => ['your-action-add'],
    'urlRemove' => ['your-action-remove'],
    'inputMethod' => 'textInput',
    'inputMethodArgs' => [['maxlength' => true]],
    'form' => $form,
    'models' => $models,
    'attribute' => 'attribute',
]);

@hik200
Copy link
Author

hik200 commented Sep 6, 2016

image

This error: Call to a member function formName() on string.

This is form begin:

$form = ActiveForm::begin([
            'method' => 'post',
            'action' => ['edit/editfilm'],
            'id' => 'hasEditable',
        ]);

@bupy7
Copy link
Owner

bupy7 commented Sep 7, 2016

Once again, you need specify an ARRAY MODELS and not just a MODEL. You $modele is JUST A MODEL. One model and that's all. You need specify an ARRAY $modele. Example,

[$modele1, $modele2, $modele3, $modele4] // and etc

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

No branches or pull requests

2 participants