Kartavya Desai

Yes, It worked like this.

Files: Requires logging in to the Slack workspace to view/download
Untitled (PHP)
Kartavya Desai

It is giving invalid model class when I have used this..

Files: Requires logging in to the Slack workspace to view/download
Untitled (PHP)
firesphere

You can see how it works in the ModelAdmin code:

  1. /**
  2.   * @return \SilverStripe\ORM\ArrayList An ArrayList of all managed models to build the tabs for this ModelAdmin
  3.   */
  4. protected function getManagedModelTabs()
  5. {
  6. $models = $this->getManagedModels();
  7. $forms = new ArrayList();
  8.  
  9. foreach ($models as $class => $options) {
  10. $forms->push(new ArrayData(array(
  11. 'Title' => $options['title'],
  12. 'ClassName' => $class,
  13. 'Link' => $this->Link($this->sanitiseClassName($class)),
  14. 'LinkOrCurrent' => ($class == $this->modelClass) ? 'current' : 'link'
  15. )));
  16. }
  17.  
  18. return $forms;
  19. }
firesphere

^^ See edited, that should work... possibly with a bit of tweaking as it's not one-on-one code from me usually 🙂

Kartavya Desai

I think it can be done using ModelAdmin but don't know how.

firesphere

I think it's by assigning it... Something like this:

  1. private static $managed_models = [
  2. 'MyModel' => ['Title' => 'My Awesome Model'],
  3. ];