Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
FIX, cleaning up a few things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Glasl committed Nov 18, 2017
1 parent 3b884ff commit 79d1060
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/objects/MediaPageAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace nglasl\mediawesome;

use SilverStripe\Forms\DateField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\ORM\DataObject;

Expand All @@ -24,30 +25,44 @@ class MediaPageAttribute extends DataObject {
);

private static $summary_fields = array(
'MediaAttribute.Title',
'Title',
'Content'
);

private static $field_labels = array(
'MediaAttribute.Title' => 'Title'
);

public function canDelete($member = null) {

return false;
}

public function getTitle() {

return $this->MediaAttribute()->Title;
}

public function getCMSFields() {

$fields = parent::getCMSFields();
$fields->removeByName('MediaPageID');
$fields->removeByName('MediaAttributeID');

// This is most commonly a simple attribute, so a HTML field only complicates things for the user.
// Determine the field type.

if(strrpos($this->getTitle(), 'Date')) {

// The user expects this to be a date attribute.

$fields->replaceField('Content', DateField::create(
'Content'
));
}
else {

// This is most commonly a simple attribute, so a HTML field only complicates things for the user.

$fields->replaceField('Content', TextareaField::create(
'Content'
));
$fields->replaceField('Content', TextareaField::create(
'Content'
));
}

// Allow extension customisation.

Expand Down

0 comments on commit 79d1060

Please sign in to comment.