Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions

Problem with search and scaffolded searchform


9 Posts   2737 Views


27 April 2010 at 11:09pm (Last edited: 27 April 2010 11:09pm), Community Member, 12 Posts

This became more complicated than i thought. :-(

Filtering while searching is of course much better. Should have thought about that. Thank you guys.
But i cannot push a new Hiddenfield into the searchform since that value doesn't exist in the searchContext. Even if I do that the search ignores that field.

I guess it would be possible to push something similar into $context but that is to complex of a variable for me to understand when i print_r it.

Adding a new value to searchable_fields on the dataobject (so that it will be included in defaultSearchContext) works. I can then remove the field from the form and then add the key-value pair again right before doing the search:

$context = singleton('Apartment')->getDefaultSearchContext();
//Add fields so that only published are shown and only related.
$data['ApartmentStatus'] = "Publicerad";
$data['ApartmentListID'] = $this->ID;
$results = $context->getResults($data);

Thanks again!