Alleviate the Search Widget of its need for a <form> tag

This commit is contained in:
Sam Georges 2014-09-06 14:03:37 +10:00
parent 33922f2180
commit df26e201df
2 changed files with 23 additions and 18 deletions

View File

@ -102,7 +102,7 @@ class Search extends WidgetBase
/*
* Save or reset search term in session
*/
$this->setActiveTerm(post('term'));
$this->setActiveTerm(post($this->getName()));
/*
* Trigger class event, merge results as viewable array
@ -133,4 +133,13 @@ class Search extends WidgetBase
$this->activeTerm = $term;
}
/**
* Returns a value suitable for the field name property.
* @return string
*/
public function getName()
{
return $this->alias . '[term]';
}
}

View File

@ -1,17 +1,13 @@
<?= Form::ajax($this->getEventHandler('onSubmit')) ?>
<div class="loading-indicator-container size-input-text">
<input
placeholder="<?= $placeholder ?>"
type="text"
name="term"
value="<?= $value ?>"
data-request="<?= $this->getEventHandler('onSubmit') ?>"
data-track-input
data-load-indicator
data-load-indicator-opaque
class="form-control <?= $cssClasses ?>"
autocomplete="off" />
</div>
<?= Form::close() ?>
<div class="loading-indicator-container size-input-text">
<input
placeholder="<?= $placeholder ?>"
type="text"
name="<?= $this->getName() ?>"
value="<?= $value ?>"
data-request="<?= $this->getEventHandler('onSubmit') ?>"
data-track-input
data-load-indicator
data-load-indicator-opaque
class="form-control <?= $cssClasses ?>"
autocomplete="off" />
</div>