/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UnidadPeso::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', 'descripcion', $this->descripcion]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUnidadPeso()
 {
     return $this->hasOne(UnidadPeso::className(), ['id' => 'unidadPeso_id']);
 }
Ejemplo n.º 3
0
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'descripcion', ['hintType' => ActiveField::HINT_SPECIAL, 'hintSettings' => ['placement' => 'right', 'onLabelClick' => true, 'onLabelHover' => false]])->textArea(['id' => 'descripcion', 'placeholder' => 'Ingrese descripción...', 'rows' => 4])->hint('Ingrese descripión. Recuerde que esa información en la que aparece en la web.');
?>
        </div>
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'notas')->textarea(['rows' => 4]);
?>
        </div>
    </div>
    
    <?php 
$dataUnidadMedida = ArrayHelper::map(\app\models\UnidadMedida::find()->asArray()->all(), 'id', 'descripcion');
$dataUnidadPeso = ArrayHelper::map(\app\models\UnidadPeso::find()->asArray()->all(), 'id', 'descripcion');
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 4, 'attributes' => ['ancho' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Ancho...']], 'largo' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Largo...']], 'alto' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Alto...']], 'unidadMedida_id' => ['type' => Form::INPUT_WIDGET, 'label' => 'Unidad de Medida', 'widgetClass' => '\\kartik\\widgets\\Select2', 'options' => ['data' => $dataUnidadMedida]]]]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 4, 'attributes' => ['diametroInterno' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Diametro Interno...']], 'diametroExterno' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Diametro Externo...']], 'peso' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Peso...']], 'unidadPeso_id' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'label' => 'Unidad de Peso', 'options' => ['data' => ArrayHelper::map(\app\models\UnidadPeso::find()->orderBy('descripcion')->asArray()->all(), 'id', 'descripcion')]]]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
 /**
  * Finds the UnidadPeso model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UnidadPeso the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UnidadPeso::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }