Bootstrap\View\Helper\BootstrapFormHelper::searchForm PHP Метод

searchForm() публичный Метод

Create a basic bootstrap search form.
public searchForm ( $model = null, $options = [], $inpOpts = [], $btnOpts = [] )
$model The model of the form
$options The options that will be pass to the BootstrapForm::create method
$inpOpts The options that will be pass to the BootstrapForm::input method
$btnOpts The options that will be pass to the BootstrapForm::button method Extra options: - id ID of the input (and fieldname) - label The input label (default false) - placeholder The input placeholder (default "Search... ") - button The search button text (default: "Search") - _input Options for the input (overrided by $inpOpts) - _button Options for the button (overrided by $btnOpts)
    public function searchForm($model = null, $options = [], $inpOpts = [], $btnOpts = [])
    {
        $options += ['id' => 'search', 'label' => false, 'placeholder' => 'Search... ', 'button' => 'Search', '_input' => [], '_button' => []];
        $options = $this->addClass($options, 'form-search');
        $btnOpts += $options['_button'];
        unset($options['_button']);
        $inpOpts += $options['_input'];
        unset($options['_input']);
        $inpOpts += ['id' => $options['id'], 'placeholder' => $options['placeholder'], 'label' => $options['label']];
        unset($options['id']);
        unset($options['label']);
        unset($options['placeholder']);
        $btnName = $options['button'];
        unset($options['button']);
        $inpOpts['append'] = $this->button($btnName, $btnOpts);
        $options['inline'] = (bool) $inpOpts['label'];
        $output = '';
        $output .= $this->create($model, $options);
        $output .= $this->input($inpOpts['id'], $inpOpts);
        $output .= $this->end();
        return $output;
    }