harvs1789uk

Perhaps I should be looking at ModelAdmin::getSearchContext() and overloading the default search fields there?

harvs1789uk

Or did that never exist and I am mixing it up with something like

  1. GridFieldEditableColumns::setDisplayFields(
  2. 'Number' => array(
  3. 'title' => 'Number',
  4. 'field' => 'LiteralField'
  5. ),
  6. 'Title' => array(
  7. 'title' => 'Title',
  8. 'field' => 'LiteralField'
  9. ),
  10. 'Notes' => array(
  11. 'title' => 'Notes',
  12. 'callback' => function($record, $column, $grid) {
  13. $field = new TextareaField($column);
  14. $field->setRows(2);
  15. return $field;
  16. }
  17. )
  18. )
  19. );
harvs1789uk

That doesn't seem to be documented any more though and I get the below when trying to /dev/build, has this functionality been removed, or am I just doing it wrong?

>>>Fatal error: Constant expression contains invalid operations

harvs1789uk

$searchable_fields (docs - https://docs.silverstripe.org/en/4/developer_guides/model/scaffolding/#searchable-fields) I am sure it used to be possible to pass a callback function (which built and returned a FormField) when using the array notation, i.e. something like:

  1. private static $searchable_fields = [
  2. 'Title',
  3. 'Type' => [
  4. 'title' => 'Type',
  5. 'field' => function() {
  6. return DropdownField::create('Type')
  7. ->setSource(static::$types);
  8. }
  9. ]
  10. ];
harvs1789uk

Ah, I suspect it is showing me draft objects because I am logged in as admin right...

harvs1789uk

Wait...I am not even using getComponents() 🤦 I have this:

  1. $list = CreativeWork::get()
  2. ->sort([
  3. 'Created' => 'DESC',
  4. 'ID' => 'ASC'
  5. ]);
harvs1789uk

Possibly a dumb question....but is there anyway to limit getComponents() to only return published objects?

Is the only way to consider stages MyChildObject::get()->filter(['ParentID' => $myParentObj->ID]); or is there a better way?