/** * Helper function to create a Radio field. Useful for quick adding it to a ComponentCollection * * @param string $name The field's HTML name attribute. * @param string $label The label text to display next to this field (defaults to '') * @param string $id The unique id of this component (defaults to an auto-assigned id). * @return PhpExt_Form_Radio */ public static function createRadio($name, $label = null, $id = null, $inputValue = null) { $c = new PhpExt_Form_Radio(); $c->setName($name); if ($label !== null) { $c->setFieldLabel($label); } if ($id !== null) { $c->setId($id); } if ($inputValue !== null) { $c->setInputValue($inputValue); } return $c; }
$opt_tipo_flotante = new PhpExt_Form_Radio(); $opt_tipo_flotante->setBoxLabel("Flotante")->setValue("float")->setName("opt-tipo-cambio"); $opt_tipo_flotante->setChecked(true); $opt_group_tipo_cambio = new PhpExt_Form_RadioGroup(); $opt_group_tipo_cambio->setfieldLabel("Tipo de cambio"); $opt_group_tipo_cambio->addItem($opt_tipo_fijo); $opt_group_tipo_cambio->addItem($opt_tipo_flotante); $group_render = "\n\nvar formulario = this.findParentByType('form');\nvar group = formulario.findBy( function(c){ return ( c.xtype == 'radiogroup' );} );\nopt = this.items.items[0];\t\nvar opt2 = this.items.items[1];\t\n\nopt.on( 'check' , function(t,n,o){\n\tvar field = formulario.getForm().findField('txt_valor');\n\tif( !group[1].items.items[0].getValue() ){ \n\t\tif( t.getValue() )\n\t\t{\n\t\t\tfield.enable();\n\t\t\tfield.focus(true);\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfield.setValue('1');\n\t\t\tfield.disable();\t\t\n\t\t}\n\t}\n});\n\nopt2.on( 'check', function(t,n,o){\n\nif( group[1].items.items[0].getValue() ){ \n\tt.setValue(false);\n\topt.setValue(true);\n}\n\n});\n\n"; $opt_group_tipo_cambio->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $group_render, array("group")))); $opt_tipo_fijo->setEnableKeyEvents(true); //VALOR DE LA MONEDA $txt_valor = PhpExt_Form_NumberField::createNumberField("txt_valor", "Valor")->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)->setDecimalSeparator($separador_decimal)->setValue(1)->setDisabled(true)->setWidth($field_width); //MONEDA PREDETERMINADA $opt_predeterminada_si = new PhpExt_Form_Radio(); $opt_predeterminada_si->setBoxLabel("Si")->setValue("yes")->setName("opt-predeterminada"); $opt_predeterminada_no = new PhpExt_Form_Radio(); $opt_predeterminada_no->setBoxLabel("No")->setValue("no")->setName("opt-predeterminada"); $opt_predeterminada_no->setChecked(true); $opt_group_predeterminada = new PhpExt_Form_RadioGroup(); $opt_group_predeterminada->setfieldLabel("Predeterminada"); $opt_group_predeterminada->addItem($opt_predeterminada_si); $opt_group_predeterminada->addItem($opt_predeterminada_no); $group_render = "\n\nvar formulario = this.findParentByType('form');\n\t\nvar group = formulario.findBy( function(c){ return ( c.xtype == 'radiogroup' );} );\n\nopt = this.items.items[0];\t\n\nopt.on( 'check' , function(t,n,o){\t\n\tvar field = formulario.getForm().findField('txt_valor');\n\tif( t.getValue() )\n\t{\n\t\tgroup[0].items.items[0].setValue(true);\n\t\tgroup[0].items.items[1].setValue(false);\n\t\tfield.setValue('1');\n\t\tfield.disable();\t\t\n\t}\n\telse\n\t{\n\t\tif( group[0].items.items[0].getValue() ){\n\t\t\tfield.enable();\n\t\t\tfield.focus(true);\t\t\n\t\t}else{\n\t\t\tfield.setValue('1');\n\t\t\tfield.disable();\t\t\n\t\t}\n\t}\n},this);\n"; $opt_group_predeterminada->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, $group_render, array("group")))); $opt_predeterminada_si->setEnableKeyEvents(true); //MONEDA PREDETERMINADA EN IDIOMA $idiomas_list = array(); if ($idiomas = $ari->get('agent')->getLanguages()) { foreach ($idiomas as $i) { $idiomas_list[] = array($i, $i); }