Example #1
0
 /**
  * @return array of tipos de Usuários
  */
 public static function findActives()
 {
     $query = TiposUsuario::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->andFilterWhere(['ativo' => 1]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TiposUsuario::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_tipo_usuario' => $this->id_tipo_usuario, 'ativo' => 1]);
     $query->andFilterWhere(['like', 'nome', $this->nome])->andFilterWhere(['like', 'descricao', $this->descricao]);
     return $dataProvider;
 }
Example #3
0
echo $form->field($model, 'foto')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['allowedFileExtensions' => ['jpg', 'jpeg', 'png', 'tif', 'tiff'], 'showUpload' => false, 'showRemove' => false, 'initialPreview' => [Html::img($model->getImageUrl(), ['class' => 'file-preview-image', 'alt' => 'Imagem atual', 'title' => 'Imagem Atual'])]]]);
?>

    <?php 
echo $form->field($model, 'email')->input("email");
?>
    
    <?php 
echo $form->field($model, 'password')->passwordInput(['value' => ""]);
?>

    <?php 
echo $form->field($model, 'password_repeat')->passwordInput(['value' => ""]);
?>

    <?php 
echo $form->field($model, 'id_tipo_usuario')->dropdownList(ArrayHelper::map(TiposUsuario::find()->where(['ativo' => 1])->all(), 'id_tipo_usuario', 'nome'), ['prompt' => 'Selecione o tipo de usuário']);
?>

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

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

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