Jump to:

1973 Posts in 1276 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » Problem with search and scaffolded searchform

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2520 Views
  • javelin
    Avatar
    Community Member
    12 Posts

    Re: Problem with search and scaffolded searchform Link to this post

    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!

    Javelin

    2520 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.