$fs = new PhpExt_Form_FormPanel(); $fs->setFrame(true)->setTitle("XML Form")->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_RIGHT)->setLabelWidth(85)->setWidth(340)->setWaitMsgTarget(true); // configure how to read the XML Data $reader = new PhpExt_Data_XmlReader(); $reader->setRecord("contact")->setSuccess("@success"); $reader->addField(new PhpExt_Data_FieldConfigObject("first", "name/first")); // custom mapping $reader->addField(new PhpExt_Data_FieldConfigObject("last", "name/last")); $reader->addField(new PhpExt_Data_FieldConfigObject("company", "company")); $reader->addField(new PhpExt_Data_FieldConfigObject("email", "email")); $reader->addField(new PhpExt_Data_FieldConfigObject("state", "state")); $reader->addField(new PhpExt_Data_FieldConfigObject("dob", "dob", "date", "m/d/Y")); // custom data types $fs->setReader($reader); $fs->setErrorReader(new PhpExtUx_Form_XmlErrorReader()); $fset = new PhpExt_Form_FieldSet(); $fset->setTitle("Contact Information")->setAutoHeight(true)->setDefaultType("textfield")->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 190)))->addItem(PhpExt_Form_TextField::createTextField("first", "First Name"))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email", null, PhpExt_Form_FormPanel::VTYPE_EMAIL)); $combo = PhpExt_Form_ComboBox::createComboBox("state", "State")->setValueField("abbr")->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true); $store = new PhpExt_Data_SimpleStore(); $store->addField("abbr"); $store->addField("state"); $store->setData(PhpExt_Javascript::variable("Ext.exampledata.states")); $combo->setStore($store); $fset->addItem($combo); $fset->addItem(PhpExt_Form_DateField::createDateField("dob", "Data of Birth")->setAllowBlank(false)); $fs->addItem($fset); $fs->addButton(PhpExt_Button::createTextButton("Load", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().load({url:'examples/form/xml-form.xml', waitMsg:'Loading',method: 'GET'})")))); $submitBtn = PhpExt_Button::createTextButton("Submit", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().submit({url:'examples/form/xml-errors.xml', waitMsg:'Saving Data...'})"))); $fs->addButton($submitBtn); //****************************** onReady echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), PhpExt_Javascript::assign("Ext.form.Field.prototype.msgTarget", PhpExt_Javascript::valueToJavascript(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)), $fs->getJavascript(false, "fs"), PhpExt_Javascript::assignNew("submit", $submitBtn->getJavascript()), $fs->render("form-ct"));
include_once 'PhpExt/Form/DateField.php'; include_once 'PhpExt/Form/ComboBox.php'; include_once 'PhpExtUx/Grid/CheckColumn.php'; $formatDate = PhpExt_Javascript::functionDef("formatDate", "return value ? value.dateFormat('M d, Y') : '';", array("value")); // custom column plugin example $checkColumn = new PhpExtUx_Grid_CheckColumn("Indoor?"); $checkColumn->setDataIndex("indoor"); $checkColumn->setWidth(55); // the column model has information about grid columns //dataIndex maps the column to the specific data field in // the data store (created below) // ColumnModel $txtCommon = PhpExt_Form_TextField::createTextField('txtCommon')->setAllowBlank(false); $cmbLight = PhpExt_Form_ComboBox::createComboBox("cmbLight")->setTypeAhead(true)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setTransform("light")->setLazyRender(true)->setListCssClass('x-combo-list-small'); $txtPrice = PhpExt_Form_NumberField::createNumberField("txtPrice")->setAllowBlank(false)->setAllowNegative(false)->setMaxValue(100000); $dtAvailable = PhpExt_Form_DateField::createDateField("dtAvaliable")->setFormat("m/d/y")->setMinValue("01/01/06")->setDisabledDays(array(0, 6))->setDisabledDaysText("Plants are not available on the weekends"); $colModel = new PhpExt_Grid_ColumnModel(); $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Common Name", "common", "common", 220)->setEditor($txtCommon))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Light", "light", null, 130)->setEditor($cmbLight))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", "price", 70, PhpExt_Ext::HALIGN_RIGHT, "usMoney")->setEditor($txtPrice))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Avaliable", "availDate", "availDate", 95, null, PhpExt_Javascript::variable('formatDate'))->setEditor($dtAvailable))->addColumn($checkColumn); // this could be inline, but we want to define the Plant record // type so we can add records dynamically $fields = new PhpExt_Data_FieldConfigObjectCollection(); $fields->add(new PhpExt_Data_FieldConfigObject("common", null, PhpExt_Data_FieldConfigObject::TYPE_STRING)); $fields->add(new PhpExt_Data_FieldConfigObject("botanical", null, PhpExt_Data_FieldConfigObject::TYPE_STRING)); $fields->add(new PhpExt_Data_FieldConfigObject("light")); $fields->add(new PhpExt_Data_FieldConfigObject("price", null, PhpExt_Data_FieldConfigObject::TYPE_FLOAT)); $fields->add(new PhpExt_Data_FieldConfigObject("availDate", "availability", PhpExt_Data_FieldConfigObject::TYPE_DATE, "m/d/Y")); $fields->add(new PhpExt_Data_FieldConfigObject("indoor", null, PhpExt_Data_FieldConfigObject::TYPE_BOOLEAN)); $plant = PhpExt_Data_Record::create($fields); // Reader $reader = new PhpExt_Data_XmlReader(); $reader->setRecord("plant");