Any information on adding an image field to a CRC using ClassExtender?
-
- 24,544 Posts
If you just want to store the path, it's a regular text field.
If you want to store attributes along with it, they'd either have to be separate fields or you'd have to do some custom work.
I meant having the editing field open the file browser. Like SimpleCart product pages has.
Looked up SC's javascript and found this, which I presume would go, after some modification of course, in the "MyExtraResourceFields" chunk
xtype: 'modx-combo-browser'
,fieldLabel: _('simplecart.resource.product_image')
,name: 'product_image'
,id: 'simplecart-product-resource-image'
,anchor: '100%'
,source: imageSource
,hideSourceCombo: true
,listeners: {
'select': {
fn: function(data) {
MODx.fireResourceFormChange();
var d = Ext.get('simplecart-product-resource-imagepreview');
d.update('');
if (!Ext.isEmpty(data.url)) {
var imageUrl = MODx.config.connectors_url+'system/phpthumb.php?h=150&w=200&src='+data.url+'&wctx=web&source='+imageSource;
d.update('<img src="'+imageUrl+'" alt="" />');
}
}
,scope: this
}
}
},{
html: '<div id="simplecart-product-resource-imagepreview">' +
((config.record.product_image) ? '<img src="'+MODx.config.connectors_url+'system/phpthumb.php?h=150&w=200&src='+config.record.product_image+'&wctx=web&source='+imageSource+'">' : '') +
'</div>'
,border: false
},{
-
- 24,544 Posts
That sounds right to me. CE will just respond to the field's text content on submission (assuming that it's a real submission and the fields are set in the $_POST). CE doesn't care how it gets there.