sunnysideup /
silverstripe-image-click-spots
| 1 | <?php |
||
| 2 | |||
| 3 | use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor; |
||
| 4 | use SilverStripe\Forms\GridField\GridField; |
||
| 5 | use SilverStripe\AssetAdmin\Forms\UploadField; |
||
| 6 | |||
| 7 | |||
| 8 | namespace Sunnysideup\ImageClickSpots\Extension; |
||
| 9 | |||
| 10 | |||
| 11 | class ImageClickSpotsExtension extends DataExtension |
||
| 12 | { |
||
| 13 | private static $has_one = [ |
||
| 14 | 'DataPointImage' => Image::class, |
||
| 15 | ]; |
||
| 16 | |||
| 17 | private static $has_many = [ |
||
| 18 | 'DataPoints' => DataPoints::class.'.Parent', |
||
| 19 | ]; |
||
| 20 | |||
| 21 | public function getCMSFields() |
||
| 22 | { |
||
| 23 | $fields = parent::getCMSFields(); |
||
| 24 | $fields->addFieldsToTab( |
||
| 25 | 'Root.ImageWithDataPoints', |
||
| 26 | [ |
||
| 27 | UploadField::create( |
||
| 28 | 'DataPointImage', |
||
| 29 | 'Image' |
||
| 30 | ) |
||
| 31 | ->setFolderName('data-point-images'), |
||
| 32 | GridField::create( |
||
| 33 | 'DataPoints', |
||
| 34 | 'Data Points', |
||
| 35 | $this->DataPoints(), |
||
| 36 | GridFieldConfig_RelationEditor::create() |
||
| 37 | )->setDescription('Please add as many datapoints as needed.'), |
||
| 38 | ] |
||
| 39 | ); |
||
| 40 | return $fields; |
||
| 41 | } |
||
| 42 | } |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 43 |