在我的extbase扩展程序中,我使用select city来选择城市。我想在会话中保存所选城市,然后使用城市的值进行搜索。请告诉我实现此功能的方向。
答案 0 :(得分:0)
您可以将表单数据发送到将通过存储库获取结果的操作,或者您可以将参数存储为会话。
流体形式示例:
<f:form action="search" controller="">
<label for="city-select">Select the city to search for</label>
<f:form.select name="searchString" id="city-select" options="cities" optionValueField="title" optionLabelField="title" />
</f:form>
控制器类示例:
/**
* The action search.
*
* @param string $searchString
*/
public function searchAction($searchString)
{
// Do a search by a repository function...
$result = $this->yourRepository->findbySearchSDtring($searchString);
// code ...
// Or save it to session and do other stuff.
if ($GLOBALS['TSFE']->loginUser) {
// if the user is logged in, store it in the current logged in fe_user session.
$myData = $GLOBALS['TSFE']->fe_user->setKey('user', 'mySessionData', $searchString);
} else {
// Otherwise store it in the user session.
$myData = $GLOBALS['TSFE']->fe_user->setKey('ses', 'mySessionData', $searchString);
}
// code ...
}