I’m developing a standalone time TV and would like to validate a few of my option inputs. I know what to do in terms of settings in the tpl config, but am unsure about how to stop the saving of the TV when validation fails. Currently, the fields get properly marked when entering invalid data, but the form still submits. Below is the tpl code (showing only the fields I’m wanting to validate for brevity):
<div id="tv-input-properties-form{$tv}"></div>
<script type="text/javascript">
// <![CDATA[{literal}
var params = {
{/literal}{foreach from=$params key=k item=v name='p'}
'{$k}': '{$v|escape:"javascript"}'{if NOT $smarty.foreach.p.last}, {/if}
{/foreach}{literal}
};
var oc = {
'change': {
fn: function () {
Ext.getCmp('modx-panel-tv').markDirty();
}, scope: this
}
};
MODx.load({
xtype: 'panel',
layout: 'form',
autoHeight: true,
autoWidth: true,
monitorResize: true,
cls: 'form-with-labels',
border: false,
labelAlign: 'top',
labelSeparator: '',
defaultType: 'textfield',
defaults: {
anchor: '100%',
msgTarget: 'under'
},
items: [{
xtype: 'numberfield',
allowDecimals: false,
minValue: 90,
allowNegative: false,
fieldLabel: _('xmtimetv.time_width'),
description: MODx.expandHelp ? '' : _('xmtimetv.time_width_desc'),
name: 'inopt_timeWidth',
id: 'inopt_timeWidth{/literal}{$tv}{literal}',
value: params['timeWidth'],
listeners: oc
}, {
xtype: MODx.expandHelp ? 'label' : 'hidden',
forId: 'inopt_timeWidth{/literal}{$tv}{literal}',
html: _('xmtimetv.time_width_desc'),
cls: 'desc-under'
}, {
xtype: 'numberfield',
allowDecimals: false,
minValue: 1,
maxValue: 60,
allowNegative: false,
fieldLabel: _('xmtimetv.time_increment'),
description: MODx.expandHelp ? '' : _('xmtimetv.time_increment_desc'),
name: 'inopt_timeIncrement',
id: 'inopt_timeIncrement{/literal}{$tv}{literal}',
value: params['timeIncrement'],
listeners: oc
}, {
xtype: MODx.expandHelp ? 'label' : 'hidden',
forId: 'inopt_timeIncrement{/literal}{$tv}{literal}',
html: _('xmtimetv.time_increment_desc'),
cls: 'desc-under'
}],
renderTo: 'tv-input-properties-form{/literal}{$tv}{literal}'
});
// ]]>
</script>
{/literal}
Thanks for any help you can offer!