S
S
slip312014-06-08 13:17:57
Yii
slip31, 2014-06-08 13:17:57

Single line search YII2?

There is a model "organization" with fields "name", "country", "city". How to do a single line search with typeahead attached?
Gii generates _search by default

<?php $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
    ]); ?>
  <ul>   
      <li>  <?= $form->field($model, 'name') ?></li>           
      <li>  <?= $form->field($model, 'country') ?></li>
      <li><?= $form->field($model, 'city') ?></li>
             <li>  <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn-u']) ?></li>
             <li>  <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn-u']) ?></li>
 </ul>
 <?php ActiveForm::end(); ?>

And how to make the search all the same was in one line? Make a getAll() method on the Organization model with a LIKE query on all fields?
Are there any examples? And what will it return for the widget?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-06-08
Protko @Fesor

it all comes down to name LIKE '%string%' OR city LIKE '%string%'etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question