Hey, I'm new to SS, can someone advise on the below please.
I've got a has_one setup in mysite/code/Page.php:
private static $has_one = array (
'Icons' => 'icon'
);
I just need to figure out how to create a CMS field in the form of a dropdown, that lets me assign an icon to a page. I only want to be able to assign one icon per page. To keep it D.R.Y., I'd ideally like to be able to add the icons into the CMS as data objects, which could have the same icon associated with multiple pages.
My /mysite/code/Icon.php is:
<?php
class Icon extends DataObject {
private static $db = array (
'Title' => 'Varchar',
'CSS' => 'Varchar',
);
public function getCMSFields() {
$fields = FieldList::create(
TextField::create('Title'),
TextareaField::create('CSS')
);
return $fields;
}
}