示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UnidadMedida::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', 'unidad_medida', $this->unidad_medida]);
     return $dataProvider;
 }
 /**
  * Finds the UnidadMedida model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UnidadMedida the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UnidadMedida::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUnidadMedida()
 {
     return $this->hasOne(UnidadMedida::className(), ['id' => 'unidadMedida_id']);
 }
    
     <div class="row">
        <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();
?>