Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Manufacturers::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['ID' => $this->ID]);
     $query->andFilterWhere(['like', 'Manufacturer', $this->Manufacturer]);
     return $dataProvider;
 }
Esempio n. 2
0
/* @var $form yii\widgets\ActiveForm */
$params = isset($id) ? ['id' => $id] : null;
?>

<div class="products-form">
    
    <?php 
$form = ActiveForm::begin(['action' => $model->isNewRecord ? Url::to(['products/create', 'id' => isset($id) ? $id : null, 'did' => isset($did) ? $did : null]) : Url::to(['products/update', 'id' => $model->ID])]);
?>

    <?php 
echo $form->field($model, 'Product')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'Manufacturer')->dropDownList(ArrayHelper::map(Manufacturers::find()->asArray()->all(), 'ID', 'Manufacturer'), ['prompt' => Yii::t('app', 'Select...')]);
?>

    <?php 
echo $form->field($model, 'Article')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'Description')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'Measure')->textInput();
?>

    <?php 
 /**
  * Finds the Manufacturers model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Manufacturers the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Manufacturers::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getManufacturer()
 {
     return $this->hasOne(Manufacturers::className(), ['ID' => 'Manufacturer']);
 }