I have a form that works, essentially, as a search / filter:
foreach($search_properties as $property) {
$form['properties'][$property->idProperty] = array(
'#title' => $property->Label,
'#ajax' => array(
'callback' => 'mymodule_filter_ajax',
'wrapper' => 'category-filter-result',
'method' => 'replace',
'effect' => 'fade',
)
);
switch ($property->PropertyType) {
Options are generated by taking only actually used values from possible ones:
'#options' => array_intersect_key($possible_choices, $used_values),
'#default_value' => array_keys($used_values),
Nothing interesting here, really, just set of fields that, on change, reloads a list of links using AJAX. Never submitted, never saved.
Problem is - when user clicks on a link, and then clicks browser's "back", all fields have their defaults selected again.
I'm under impression that it was not the case with Views exposed filters. I think I remember these filters was able to keep values when user went back to them. So it is possible.
What is the Drupal way to keep user-selected values in the simple scenario of a link click, and then browser's "back" button?
<div>
pointed in'wrapper' => 'category-filter-result'
is outside form. And thanks, I'm about to use session, I just believed there is another way, way I'm just missing. But confirmation there probably is none would be an acceptable answer, too.