Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

{SOLVED}how can i show calendar in modeladmin DateFiled?


Go to End


3 Posts   1262 Views

Avatar
Holoch

Community Member, 17 Posts

15 November 2014 at 3:32am

hi i have this code

class product extends DataObject {

private static $db = array (
'Name' => 'Varchar',
'Date' => 'Date',
'Descriptions' => 'Varchar',
);
private static $has_one = array('Photo' => 'Image');
}

class MyAdmin extends ModelAdmin {
private static $managed_models = array('Product'); // Can manage multiple models
private static $url_segment = 'product'; // Linked as /admin/product/
private static $menu_title = 'Product Admin';
}

And in CMS i have dateFile but i can´t find solution to show calendar.
I think i must set datefiled config but i cant find how.

Thanx a lot

and aslo in my ModelAdmin CMSView when i edit image i want to remove some fields.

Avatar
lugor

Community Member, 2 Posts

15 November 2014 at 9:45am

Edited: 15/11/2014 9:49am

Hi Holoch,

you can set calendar picker as default in your config.yml
This will add the calendar picker to every DateField.

DateField:
__default_config:
____showcalendar: true

(Indentation is important in YAML, replace "_" with spaces " ")

Avatar
Holoch

Community Member, 17 Posts

15 November 2014 at 2:48pm

Edited: 16/11/2014 1:46am

Thank you very much Lugor, it is great knowledge, i appreciates it. I find another solution i use this in Product class.

public function getCMSFields(){
$image = new UploadField('Photo', 'Image');
$image->setFolderName('Products');
$dateField = new DateField('Date', 'Datum (napr. 01/05/1984)');
$dateField->setConfig('showcalendar', true);
$dateField->setConfig('dateformat', 'dd/MM/YYYY');

$fields = new FieldList(
$image,
new TextField('Name'),
$dateField,
new TextareaField('Descriptions')
);
return $fields;
}
}
thanx and have a nice day