Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

8540 Posts in 2227 Topics by 1201 members

General Questions

SilverStripe Forums » General Questions » ModelAdmin search customization

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Page: 1
Go to End
Author Topic: ModelAdmin search customization 201 Views
  • micahsheets
    avatar
    Community Member
    130 posts

    ModelAdmin search customization Link to this post

    If I have a managed model that I want to restrict which of the DataObjects in the model can be searched for. For example I have a DataObject Student that has_one school so that some of the students have school A and some have school B. I want the ModelAdmin that is managing Students to only be able to search for students that are in School A and not School B. I would think that I could have a hidden field in the SearchForm that has the School A statically defined. I don't know how to accomplish. I want the search to work as if the person searching has put School A in the School search form but I don't actually want the person to see the form or be able to put anything in it.

    I hope this makes sense.

  • Bambii7
    avatar
    Community Member
    55 posts

    Re: ModelAdmin search customization Link to this post

    On the student dataobject there are a lot of parameters that might help to include. I'm not sure if it'll solve the issue but try adding

       static $searchable_fields = array(
          'school '
       );

    static $defaults = array(
    "school " => 'A'
    );

    And then I think you'll need to over write the modeladmin search form with $this->fields->removeByName('school ');

    I'm not that familiar with SilverStripe, let alone ModelAdmin, so this is guessing form what I've read so far

    201 Views
Page: 1
Go to Top

Currently Online: ikhwanb, holy noli, steeeo, Thomas B. Nielsen

Welcome to our latest member: holy noli

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

Comments on this website? Please give feedback.