src/Common.php
public function search($url, array $form = array())
    {
        $html = '';
        $form = array_merge(array(
            'name' => 'search',
            'role' => 'search',
            'class' => 'form-horizontal',
            'placeholder' => 'Search',
            'button' => $this->icon('search'),
            'size' => '',
        ), $form);
        $form['method'] = 'get';
        $form['action'] = $url;
        $input = array('class' => 'form-control', 'placeholder' => $form['placeholder']);
        $button = $form['button'];
        $size = $form['size'];
        unset($form['placeholder'], $form['button'], $form['size']);
        $form = new BPForm($form);
        $form->validator->set($form->header['name'], 'required');
        if (!empty($button)) {
            if (strpos($button, '<button') === false) {
                $button = '<button type="submit" class="btn btn-default" title="Search">'.$button.'</button>';
            }
            $html .= '<div class="'.$this->prefixClasses('input-group', array('sm', 'md', 'lg'), $size).'">';
            $html .= $form->text($form->header['name'], $input);
            $html .= '<div class="input-group-btn">'.$button.'</div>';
            $html .= '</div>';
        } else {
            if (!empty($size) && in_array($size, array('sm', 'md', 'lg'))) {
                $input['class'] .= " input-{$size}";
            }
            $html .= $form->text($form->header['name'], $input);
        }

        return $form->header().$html.$form->close();
    }
public function search($url, array $form = array())
    {
        $html = '';
        $form = array_merge(array(
            'name' => 'search',
            'role' => 'search',
            'class' => 'form-horizontal',
            'placeholder' => 'Search',
            'button' => $this->icon('search'),
            'size' => '',
        ), $form);
        $form['method'] = 'get';
        $form['action'] = $url;
        $input = array('class' => 'form-control', 'placeholder' => $form['placeholder']);
        $button = $form['button'];
        $size = $form['size'];
        unset($form['placeholder'], $form['button'], $form['size']);
        $form = new BPForm($form);
        $form->validator->set($form->header['name'], 'required');
        if (!empty($button)) {
            if (strpos($button, '<button') === false) {
                $button = '<button type="submit" class="btn btn-default" title="Search">'.$button.'</button>';
            }
            $html .= '<div class="'.$this->prefixClasses('input-group', array('sm', 'md', 'lg'), $size).'">';
            $html .= $form->text($form->header['name'], $input);
            $html .= '<div class="input-group-btn">'.$button.'</div>';
            $html .= '</div>';
        } else {
            if (!empty($size) && in_array($size, array('sm', 'md', 'lg'))) {
                $input['class'] .= " input-{$size}";
            }
            $html .= $form->text($form->header['name'], $input);
        }

        return $form->header().$html.$form->close();
    }
public function search ( $ url , array $ form = array ( ) ) { $ html = '' ; $ form = array_merge ( array ( 'name' => 'search' , 'role' => 'search' , 'class' => 'form-horizontal' , 'placeholder' => 'Search' , 'button' => $ this -> icon ( 'search' ) , 'size' => '' , ) , $ form ) ; $ form [ 'method' ] = 'get' ; $ form [ 'action' ] = $ url ; $ input = array ( 'class' => 'form-control' , 'placeholder' => $ form [ 'placeholder' ] ) ; $ button = $ form [ 'button' ] ; $ size = $ form [ 'size' ] ; unset ( $ form [ 'placeholder' ] , $ form [ 'button' ] , $ form [ 'size' ] ) ; $ form = new BPForm ( $ form ) ; $ form -> validator -> set ( $ form -> header [ 'name' ] , 'required' ) ; if ( ! empty ( $ button ) ) { if ( strpos ( $ button , '<button' ) === false ) { $ button = '<button type="submit" class="btn btn-default" title="Search">' . $ button . '</button>' ; } $ html .= '<div class="' . $ this -> prefixClasses ( 'input-group' , array ( 'sm' , 'md' , 'lg' ) , $ size ) . '">' ; $ html .= $ form -> text ( $ form -> header [ 'name' ] , $ input ) ; $ html .= '<div class="input-group-btn">' . $ button . '</div>' ; $ html .= '</div>' ; } else { if ( ! empty ( $ size ) && in_array ( $ size , array ( 'sm' , 'md' , 'lg' ) ) ) { $ input [ 'class' ] .= " input-{$size}" ; } $ html .= $ form -> text ( $ form -> header [ 'name' ] , $ input ) ; } return $ form -> header ( ) . $ html . $ form -> close ( ) ; }
This will assist you in creating a search bar for your site.

@param string $url  This is the url that you would like the search term to be sent to
@param array  $form To customize the form, you can submit an array with any of the following keys:

- '**name**' - The name of the input field. The default is '**search**'.
- '**placeholder**' - Subtle text to indicate what sort of field it is. The default is '**Search**'.
- '**button**' - The button itself with tags and all, or just a name. The default is ``$bp->icon('search')``.
- If you don't want a button at all then just give this an empty value.
- '**class**' - Any special class(es) to give the ``<form>`` tag. The default is '**form-horizontal**'.
- '**size**' - Either '**sm**', '**md**' (the default), or '**lg**'.

@return string

@example

```php
echo $bp->search('http://example.com');
```
This will assist you in creating a search bar for your site .