/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = OrganizacionTipo::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; }
/** * Finds the OrganizacionTipo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return OrganizacionTipo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = OrganizacionTipo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use kartik\builder\Form; use kartik\widgets\FileInput; /* @var $this yii\web\View */ /* @var $model app\models\Organizacion */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="organizacion-form"> <?php $form = ActiveForm::begin(['type' => ActiveForm::TYPE_VERTICAL, 'options' => ['enctype' => 'multipart/form-data']]); ?> <?php //echo $form->field($model, 'id')->textInput() $dataOrg = ArrayHelper::map(\app\models\OrganizacionTipo::find()->asArray()->all(), 'id', 'descripcion'); echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['id' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nombre...']], 'nombre' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nombre...']], 'organizacionTipo_id' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\widgets\\Select2', 'options' => ['data' => $dataOrg]], 'telefono' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nro Inventario...']]]]); echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 5, 'attributes' => ['direccion' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nombre...']], 'ciudad' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nro Inventario...']], 'cp' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nombre...']], 'provincia' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nro Inventario...']], 'pais' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nro Inventario...']]]]); echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 2, 'attributes' => ['email' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nombre...']], 'sitioWeb' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nro Inventario...']]]]); echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 2, 'attributes' => ['info' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => 'Nombre...']], 'nuestrasColecciones' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => 'Nro Inventario...']]]]); echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 5, 'attributes' => ['facebook' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nombre...']], 'twitter' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nro Inventario...']], 'instagram' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nombre...']], 'googleMas' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nro Inventario...']], 'linkedin' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nro Inventario...']]]]); // your fileinput widget for single file upload echo $form->field($model, 'imagen')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['allowedFileExtensions' => ['jpg', 'gif', 'png']]]); ?> <?php echo $form->field($model, 'mapaLink')->textInput(['maxlength' => true]); ?> <div class="form-group"> <?php
/** * @return \yii\db\ActiveQuery */ public function getOrganizacionTipo() { return $this->hasOne(OrganizacionTipo::className(), ['id' => 'organizacionTipo_id']); }