Improve search_form() for external use

pull/5735/merge
Aleksander Machniak 7 years ago
parent ff55fa622f
commit 418c72137e

@ -2035,7 +2035,7 @@ EOF;
* *
* @return string HTML code for the gui object * @return string HTML code for the gui object
*/ */
protected function search_form($attrib) public function search_form($attrib)
{ {
// add some labels to client // add some labels to client
$this->add_label('searching'); $this->add_label('searching');
@ -2056,14 +2056,16 @@ EOF;
$input_q = new html_inputfield($attrib); $input_q = new html_inputfield($attrib);
$out = $label . $input_q->show(); $out = $label . $input_q->show();
// @TODO: At some point we'll need support for multiple searchforms on the same page // Support for multiple searchforms on the same page
$this->add_gui_object('qsearchbox', $attrib['id']); if ($attrib['gui-object'] !== false && $attrib['gui-object'] !== 'false') {
$this->add_gui_object($attrib['gui-object'] ?: 'qsearchbox', $attrib['id']);
}
// add form tag around text field // add form tag around text field
if (empty($attrib['form']) && empty($attrib['no-form'])) { if (empty($attrib['form']) && empty($attrib['no-form'])) {
$out = $this->form_tag(array( $out = $this->form_tag(array(
'name' => "rcmqsearchform", 'name' => $attrib['form-name'] ?: 'rcmqsearchform',
'onsubmit' => self::JS_OBJECT_NAME . ".command('search'); return false", 'onsubmit' => sprintf("%s.command('%s'); return false", self::JS_OBJECT_NAME, $attrib['command'] ?: 'search'),
// 'style' => "display:inline" // 'style' => "display:inline"
), $out); ), $out);
} }
@ -2099,7 +2101,7 @@ EOF;
$reset_button = $this->button(array( $reset_button = $this->button(array(
'type' => 'link', 'type' => 'link',
'command' => 'reset-search', 'command' => $attrib['reset-command'] ?: 'reset-search',
'class' => 'button reset', 'class' => 'button reset',
'label' => 'resetsearch', 'label' => 'resetsearch',
'title' => 'resetsearch', 'title' => 'resetsearch',

Loading…
Cancel
Save