/**
  * Creates a new Veiculo model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Veiculo();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->renavam]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Veiculo model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Veiculo();
     if ($model->load(Yii::$app->request->post())) {
         $model->datacompra = implode("-", array_reverse(explode("/", $_POST['Veiculo']['datacompra'])));
         if ($model->save()) {
             foreach ($_POST['Veiculo']['atributoveiculos'] as $key => $value) {
                 $atributo = new Atributoveiculo();
                 $atributo->descricaoatributo = $value;
                 $atributo->idveiculo = $model->idveiculo;
                 if ($atributo->save()) {
                     return $this->redirect(['view', 'id' => $model->idveiculo]);
                 } else {
                     return $this->render('create', ['model' => $model]);
                 }
             }
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }