Code:
<script type="text/javascript">
function add_record() {
var comment_win = new Ext.Window({
el:'add_record',
layout:'fit',
width:500,
height:300,
closeAction:'hide',
plain: true,
buttons: [{
text:'Submit',
handler: function() {
comment_form.getForm().submit({
method:'GET',
waitTitle:'Connecting',
waitMsg:'Sending data...',
// Functions that fire (success or failure) when the server responds.
// The one that executes is determined by the
// response that comes from login.asp as seen below. The server would
// actually respond with valid JSON,
// something like: response.write "{ success: true}" or
// response.write "{ success: false, errors: { reason: 'Login failed. Try again.' }}"
// depending on the logic contained within your server script.
// If a success occurs, the user is notified with an alert messagebox,
// and when they click "OK", they are redirected to whatever page
// you define as redirect.
success:function(){
comment_win.hide();
},
// Failure function, see comment above re: success and failure.
// You can see here, if login fails, it throws a messagebox
// at the user telling him / her as much.
failure:function(form, action){
comment_form.getForm().reset();
comment_win.hide();
}
});
}
},{
text: 'Close',
handler: function(){
comment_win.hide();
}
}]
});
var comment_form = new Ext.form.FormPanel({
labelWidth: 75,
url: '{{$html->url('/admin/users/addnewuser')}}/',
defaultType: 'textfield',
defaults: {width: 230},
items: [
{
fieldLabel: 'Login Name',
name: 'login_name',
allowBlank: false
},
{
fieldLabel: 'First Name',
name: 'first_name',
allowBlank: false
},
{
fieldLabel: 'Last Name',
name: 'last_name',
allowBlank: false
}, new Ext.form.ComboBox ({
fieldLabel: 'Group',
name: 'Group',
store:
new Ext.data.SimpleStore({
fields: ["display_field", "value"],
data: [
{{php}}
// get groups
$groups = $this->_tpl_vars['groups'];
// this holds data
$temp = '';
$num = 0;
// loops through/gets data
foreach($groups as $k=>$v) {
$temp .= "['".$v."', '".$num."'],";
$num++;
}
// removes last comma
$temp = substr($temp, 0, strlen($temp)-1);
echo $temp;
{{/php}}
]
}),
mode: 'local',
displayField: 'display_field',
valueField: 'value'
}),new Ext.form.ComboBox ({
fieldLabel: 'Subarea',
name: 'Subarea',
store:
new Ext.data.SimpleStore({
fields: ["display_field2", "value2"],
data: [
{{php}}
// get groups
$subarealist = $this->_tpl_vars['subarealist'];
// this holds data
$temp = '';
// loops through/gets data
$num = 0;
foreach($subarealist as $k=>$v) {
$temp .= "['".$v."', '".$num."'],";
$num++;
}
// removes last coma
$temp = substr($temp, 0, strlen($temp)-1);
echo $temp;
{{/php}}
]
}),
mode: 'local',
displayField: 'display_field2',
valueField: 'value2'
}),new Ext.form.ComboBox ({
fieldLabel: 'ReportTo',
name: 'ReportTo',
store:
new Ext.data.SimpleStore({
fields: ["display_field3", "value3"],
data: [
{{php}}
// get groups
$reporttolist = $this->_tpl_vars['reporttolist'];
// this holds data
$temp = '';
// loops through/gets data
$num = 0;
foreach($reporttolist as $k=>$v) {
$temp .= "['".$k."', '".$num."'],";
$num++;
}
// removes last coma
$temp = substr($temp, 0, strlen($temp)-1);
echo $temp;
{{/php}}
]
}),
mode: 'local',
displayField: 'display_field3',
valueField: 'value3'
}), {
fieldLabel: 'City',
name: 'city',
allowBlank: false
}
]
});
comment_win.add(comment_form);
comment_win.show();
return false;
}
</script>
Any advice?