/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Candidato::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(['idcandidato' => $this->idcandidato, 'nascimento' => $this->nascimento]);
     $query->andFilterWhere(['like', 'nome', $this->nome])->andFilterWhere(['like', 'documento', $this->documento])->andFilterWhere(['like', 'cpf', $this->cpf])->andFilterWhere(['like', 'endereco', $this->endereco])->andFilterWhere(['like', 'bairro', $this->bairro])->andFilterWhere(['like', 'cep', $this->cep])->andFilterWhere(['like', 'telefone', $this->telefone]);
     return $dataProvider;
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCandidatoIdcandidato()
 {
     return $this->hasOne(Candidato::className(), ['idcandidato' => 'candidato_idcandidato']);
 }
 /**
  * Finds the Candidato model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Candidato the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Candidato::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #4
0
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\select2\Select2;
/* @var $this yii\web\View */
/* @var $model backend\models\Inscricao */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="inscricao-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <?php 
$candidatoArray = ArrayHelper::map(\backend\models\Candidato::find()->orderBy('nome')->all(), 'idcandidato', 'nome');
?>
    <?php 
echo $form->field($model, 'candidato_idcandidato')->widget(Select2::classname(), ['data' => $candidatoArray, 'options' => ['placeholder' => 'Selecione um Candidato ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
    <?php 
echo $form->field($model, 'candidato_idcandidato')->dropDownList($candidatoArray, ['prompt' => '---- Selecione um Candidato ----'])->label('Candidato');
?>

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

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