<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;

?>

<div class="h_a">搜索</div>
<?php
$action = isset($action) ? $action : $this->context->id . '/index';
$searchForm = ActiveForm::begin([ 'id' => 'search-form', 'action' => [$action], 'method' => 'get']);
?>
<div class="search_type cc mb10">
    <span class="mr20">关键字：<input type="text" class="input length_2" value="<?= (isset($get['keywords'])) ? Html::encode($get['keywords']) : '' ?>" name="keywords"></span>
    <span class="mr20">搜索类型：
        <select class="select_2" name="search_field">
            <?php  foreach ($model->search() as $field => $name) : ?>
                <option <?= (isset($get['search_field']) && ($get['search_field'] == $field)) ? 'selected="selected"' : ''; ?> value="<?= $field ?>" ><?= $name ?></option>
            <?php endforeach; ?>
        </select>
    </span>
    <button class="btn">搜索</button>
</div>
<?php ActiveForm::end(); ?>