Beispiel #1
0
$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"));
Beispiel #2
0
$time = PhpExt_Form_TimeField::createTimeField("time", "Time")->setMinValue("8:00am")->setMaxValue("6:00pm");
$simple->addItem($firstName)->addItem($lastName)->addItem($company)->addItem($email)->addItem($time);
$simple->addButton(PhpExt_Button::createTextButton("Save"));
$simple->addButton(PhpExt_Button::createTextButton("Cancel"));
//****************************** Adding Fieldset
$fsf = new PhpExt_Form_FormPanel();
$fsf->setLabelWidth(75)->setUrl("save-form.php")->setFrame(true)->setTitle("Simple Form with FieldSets")->setBodyStyle("padding:5px 5px 0")->setWidth(350);
//- Fielset 1
$fieldset1 = new PhpExt_Form_FieldSet();
$fieldset1->setCheckboxToggle(true)->setTitle("User Information")->setAutoHeight(true)->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 210)))->setCollapsed(true);
// Use the helper function to easily create fields to add them inline
$fieldset1->addItem(PhpExt_Form_TextField::createTextField("first", "First Name")->setAllowBlank(false))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email")->setVType(PhpExt_Form_FormPanel::VTYPE_EMAIL));
$fsf->addItem($fieldset1);
//- Fieldset 2
$fieldset2 = new PhpExt_Form_FieldSet();
$fieldset2->setTitle("Phone Number")->setCollapsible(true)->setAutoHeight(true)->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 210)))->addItem(PhpExt_Form_TextField::createTextField("home", "Home")->setValue("(888) 555-1212"))->addItem(PhpExt_Form_TextField::createTextField("business", "Business"))->addItem(PhpExt_Form_TextField::createTextField("mobile", "Mobile"))->addItem(PhpExt_Form_TextField::createTextField("fax", "Fax"));
$fsf->addItem($fieldset2);
//- Buttons
$fsf->addButton(PhpExt_Button::createTextButton("Save"));
$fsf->addButton(PhpExt_Button::createTextButton("Cancel"));
//****************************** A little more complex
$top = new PhpExt_Form_FormPanel();
$top->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_TOP)->setFrame(true)->setTitle("Multi Column, Nested Layouts and Anchoring")->setBodyStyle("padding:5px 5px 0")->setWidth(600);
$columnPanel = new PhpExt_Panel();
// using ColumnLayout
$columnPanel->setLayout(new PhpExt_Layout_ColumnLayout());
$top->addItem($columnPanel);
//- First column
$firstColumn = new PhpExt_Panel();
// Use FormLayout to enable field labels and autoarrange fields on the panel
$firstColumn->setLayout(new PhpExt_Layout_FormLayout());