Code:
Ext.define('Santi.view.Product.NewProductForm', { extend: 'Ext.form.Panel',
alias: 'widget.productform',
autoHeight: true,
width: '100%',
border: 0,
initComponent: function() {
this.items = [
{
xtype: 'fieldset',
plain: true,
frame: true,
border: 0,
bodyPadding: 5,
defaults: {
xtype: 'textfield',
labelWidth: 130,
inputType: 'text',
anchor: '50%',
selectOnFocus: true,
required: true
},
items: [
{
itemId: 'name',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.name'),
name: 'name'
},
{
xtype: 'checkboxgroup',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.available_size'),
columns: 3,
vertical: true,
items: [
{
boxLabel: 'XS',
name: 'item_size',
inputValue: '0'
},
{
boxLabel: 'S',
name: 'item_size',
inputValue: '1'
},
{
boxLabel: 'M',
name: 'item_size',
inputValue: '2'
},
{
boxLabel: 'L',
name: 'item_size',
inputValue: '3'
},
{
boxLabel: 'XL',
name: 'item_size',
inputValue: '4'
},
{
boxLabel: 'XXL',
name: 'item_size',
inputValue: '5'
},
{
boxLabel: 'one-size',
name: 'item_size',
inputValue: '6'
}
]
},
{
xtype: 'textareafield',
itemId: 'description',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.description'),
name: 'description',
grow : true,
anchor : '60%'
},
{
xtype: 'filefield',
id: 'photo1',
name: 'photo1',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.photo')+' 1',
msgTarget: 'side',
allowBlank: true,
anchor: '60%',
buttonText: Ext.i18n.appBundle.getMsg('productForm.photo_select'),
validator: this.isPicture
},
{
xtype: 'filefield',
name: 'photo2',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.photo')+' 2',
msgTarget: 'side',
allowBlank: true,
anchor: '60%',
buttonText: Ext.i18n.appBundle.getMsg('productForm.photo_select'),
validator: this.isPicture
},
{
xtype: 'filefield',
name: 'photo3',
fieldLabel: Ext.i18n.appBundle.getMsg('productForm.photo')+' 3',
msgTarget: 'side',
allowBlank: true,
anchor: '60%',
buttonText: Ext.i18n.appBundle.getMsg('productForm.photo_select'),
validator: this.isPicture
},
{
xtype: 'button',
type: 'reset',
text: Ext.i18n.appBundle.getMsg('productForm.reset'),
handler: function() {
this.up('form').getForm().reset();
},
region: 'east',
anchor: '20%',
margin: '20 0 0 10'
}
]
}
];
this.callParent(arguments);
},
setDefaultValue: function() {
var me = this.me;
var combo = me.down('combobox[name=client_type_id]');
combo.setValue(this.client_type_id);
},
isPicture: function() {
if(this.getValue().length == 0){
return true;
}
var imageRegex = /(\.|\/)(gif|jpe?g|png|bmp)$/i;
if(this.getValue().match(imageRegex) == null) {
return Ext.i18n.appBundle.getMsg('productForm.photo_invalid');
}
else {
return true;
}
}
});
And in PHP