Hi all,
I’m using SqlDataProvider to obtain 95 records from a table. This works fine for gridview in my index file. When I select update on a particular ‘id’ the error:
Unknown Method – yii\base\UnknownMethodException Calling unknown method: yii\data\SqlDataProvider::isAttributeRequired()
** Note: I’ve printed $model from the update view file & it renders the following record info correctly:
yii\data\SqlDataProvider Object
(
[db] => yii\db\Connection Object
(
[dsn] => mysql:host=l
…
Controller:
public function actionUpdate($id)
{
$this->layout = 'accessLayout';
$searchModel = new CarriersSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$sql = 'SELECT *
FROM carriers
WHERE (Latitude < 37.760004 + 1)
AND (Longitude < -85.712624 + 1)
AND (Latitude > 37.760004 - 1)
AND (Longitude > -85.712624 - 1) ';
$sqlProvider = new SqlDataProvider([
'sql' => $sql,
]);
$model = $sqlProvider->getModels();
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->ID]);
}
return $this->render('update', [
'model' => $model,
'sqlProvider' => $sqlProvider,
Update View:
<?= $form->field($model, 'ExecutiveGender')->textInput(['class' => 'form-control class-content-title_series', 'placeholder' => 'ExecutiveGender', 'disabled' => false])->label(false) ?></div>
Any light shed on this situation will be greatly appreciated.
Thanks,
lwood