FIX: Links Widget

This commit is contained in:
Tony Air 2024-05-06 13:03:31 +02:00
parent 7c9fa8530d
commit fab6c5f8e9
1 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,5 @@
<?php
namespace A2nt\CMSNiceties\Widgets;
use gorriecoe\Link\Models\Link;
@ -33,12 +32,19 @@ class LinksWidget extends Widget
'Links' => Link::class,
];
private static $many_many_extraFields = [
'Links' => [
'Sort' => 'Int',
],
];
private static $owns = [
'Links',
];
public function getCMSFields()
{
//die('aaa');
$fields = parent::getCMSFields();
if($this->ID) {
@ -47,11 +53,13 @@ class LinksWidget extends Widget
'Links',
$this
));
}else{
$fields->push(LiteralField::create(
'Note',
'<p class="alert alert-warning"><b>Note:</b> The widget needs to be saved before adding a link.'
.' Enter the Title and click "+ Create" button at the bottom left corner of the screen</p>')
} else {
$fields->push(
LiteralField::create(
'Note',
'<p class="alert alert-warning"><b>Note:</b> The widget needs to be saved before adding a link.'
.' Enter the Title and click "+ Create" button at the bottom left corner of the screen</p>'
)
);
}