I have a model that has a type of image field. But while trying to save the model image is not sent and when I try to send via form submit is also not sent. Follows the code:
SAVE BUTTON ACTION
Using a model with image
ps: I use rest
FORM
Code:
xtype: 'form',
//padding: '10 10 10 10',
//style: 'background-color: #fff;',
fieldDefaults: {
anchor: '100%',
labelAlign: 'left',
allowBlank: false,
combineErrors: true,
msgTarget: 'side',
padding: 10
},
items: [
{
xtype: 'textfield',
name: 'id',
fieldLabel: 'id',
hidden: true
},
{
layout: 'hbox',
items: [
{
xtype: 'textfield',
name: 'titulo',
fieldLabel: 'Titulo'
},
{
xtype: 'textfield',
name: 'fonte',
allowBlank: true,
fieldLabel: 'Fonte'
}
]
},
{
xtype: 'htmleditor',
name: 'conteudo',
fieldLabel: 'Conteúdo',
enableFont: false,
enableAlignments: false,
enableFontSize: false
},
{
xtype: 'filefield',
emptyText: 'Selecione uma imagem',
fieldLabel: 'Imagem',
name: 'imagem',
buttonConfig: {
text: '',
iconCls: 'upload-icon'
}
}
],
SAVE BUTTON ACTION
Code:
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
var novo = false;
if (values.id > 0) {
record.set(values);
} else {
record = Ext.create('ezCms.model.Noticia');
record.set(values);
Ext.getStore('noticias').add(record);
novo = true;
}
win.close();
Ext.getStore('noticias').sync();
if (novo) { //faz reload para atualziar
Ext.getStore('noticias').load();
}
Using a model with image
Aucun commentaire:
Enregistrer un commentaire