PDA

View Full Version : allow blank field/textbox to be saved



mgoodi
7 May 2016, 12:04 PM
I'm trying to allow nulls to be saved, if a value is not inputted in one of the boxes. I have the allowblank value set to true, but this won't work. Can anyone see where I'm going wrong with this?


{
xtype: 'container',
layout: 'hbox',
style: 'margin-top:20px; margin-left:30px;',
items: [
{
xtype: 'label',
html: 'Reference date for the <u>participant</u> =',
style: 'margin-right:10px; padding-top:3px;'
},
{
xtype: 'formattednumberfield',
margin: '0 5 0 0',
width: 35,
name: 'refMonth',
emptyText:'MM',
allowDecimals: false,
minValue: 1,
maxValue: 12,
hideTrigger: true,
allowBlank: true
},
{
xtype: 'numberfield',
width: 55,
name: 'refYear',
emptyText:'YYYY',
allowDecimals: false,
minValue: 1800,
hideTrigger: true,
allowBlank: true,
style: 'margin-right:10px;',
maxValue: new Date().getFullYear()
},
{
xtype: 'label',
html: '(month/year)',
style: 'padding-top:3px;'
}
]
}

jdkhamba
8 May 2016, 4:23 AM
Seems to work just fine:

https://fiddle.sencha.com/#fiddle/1a12

Are you having trouble saving on the server ? It must accept nullable numbers in that case.

mgoodi
9 May 2016, 4:34 PM
Thanks for your reply jdkhamba. Yes, I need to be able to save them as null, if nothing is entered, but on save, I get an error saying that an entry is required.