Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to provide a custom gridfield config. #26

Merged
merged 2 commits into from
Nov 30, 2018

Conversation

thepearson
Copy link
Contributor

Allows config to be customized from the parent forms. I needed the ability to allow the user to select the type of class they wanted to create.

eg.

// This helper allows us to define the types of pages we can create.
$classCreator = new GridFieldAddNewMultiClass('buttons-before-right');
$classCreator->setClasses([RelationType1::class, RelationType2::class. RelationType3::class]);

$config = [
  new GridFieldHasOneButtonRow(),
  new GridFieldSummaryField("RelationType"),
  new GridFieldHasOneUnlinkButton($this, 'buttons-before-right'),
  $classCreator
];

$fields->removeByName("RelationTypeID");
$fields->addFieldToTab("Root.Main",
  HasOneButtonField::create($this, "RelationType", null, null, $config)
);

Might be of use to other folks.

@wilr
Copy link
Contributor

wilr commented Nov 29, 2018

IMHO we need keep the method signature the same for HasOneButtonField as GridField and have a the $config argument take a GridFieldConfig rather than change the argument to an array.

Other than that makes sense!

@thepearson
Copy link
Contributor Author

Yeah cool, makes sense.

@wilr wilr merged commit 90f6486 into silvershop:master Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants