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

Fix RequiredFields validation #195

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Form/LinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
use SilverStripe\LinkField\Models\Link;
use SilverStripe\LinkField\Form\Traits\AllowedLinkClassesTrait;
use SilverStripe\LinkField\Form\Traits\LinkFieldGetOwnerTrait;
use SilverStripe\Forms\HasOneRelationFieldInterface;

/**
* Allows CMS users to edit a Link object.
*/
class LinkField extends FormField
class LinkField extends FormField implements HasOneRelationFieldInterface
{
use AllowedLinkClassesTrait;
use LinkFieldGetOwnerTrait;
Expand Down
6 changes: 5 additions & 1 deletion src/Form/Traits/LinkFieldGetOwnerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ private function getOwnerFields(): array
$relation = $this->getName();
// Elemental content block
if (class_exists(BaseElement::class) && is_a($owner, BaseElement::class)) {
// Remove namespaces from inline editable blocks
// This will return an empty array for non-inline editable blocks (e.g. blocks in a gridfield)
$arr = ElementalAreaController::removeNamespacesFromFields([$relation => ''], $owner->ID);
$relation = array_keys($arr)[0];
if (!empty($arr)) {
$relation = array_key_first($arr);
}
}
return [
'ID' => $owner->ID,
Expand Down
Loading