$newForm->table = 'orders'; $newForm->setPrimaryKeys('OrderID'); $newForm->serialKey = true; // Set Form layout $newForm->setColumnLayout('twocolumn'); $newForm->setTableStyles('width:580px;', '', ''); // Add elements $newForm->addElement('OrderID', 'hidden', array('label' => 'OrderID', 'id' => 'newForm_OrderID')); $newForm->addElement('ShipName', 'text', array('label' => 'Name', 'maxlength' => '40', 'style' => 'width:98%;', 'id' => 'newForm_ShipName')); $newForm->addElement('ShipAddress', 'text', array('label' => 'Address', 'maxlength' => '60', 'style' => 'width:98%;', 'id' => 'newForm_ShipAddress')); $newForm->addElement('ShipCity', 'text', array('label' => 'City', 'maxlength' => '15', 'size' => '20', 'id' => 'newForm_ShipCity')); $newForm->addElement('ShipPostalCode', 'text', array('label' => 'PostalCode', 'maxlength' => '10', 'size' => '20', 'id' => 'newForm_ShipPostalCode')); $newForm->addElement('ShipCountry', 'text', array('label' => 'Country', 'maxlength' => '15', 'size' => '20', 'id' => 'newForm_ShipCountry')); $newForm->addElement('Freight', 'number', array('label' => 'Freight', 'id' => 'newForm_Freight')); $newForm->addElement('newFile', 'file', array('label' => 'Attachment', 'id' => 'newForm_newFile')); $elem_9[] = $newForm->createElement('newSubmit', 'submit', array('value' => 'Submit')); $newForm->addGroup("newGroup", $elem_9, array('style' => 'text-align:right;', 'id' => 'newForm_newGroup')); // automatic file upload options $newForm->setUploadOptions('newFile', array('dir' => './', 'filetypes' => '', 'filesize' => 1048576, 'fileprefix' => '')); // Add events // Add ajax submit events $success = <<<SU function( response, status, xhr) { \$("#demo").html(response); } SU; $newForm->setAjaxOptions(array('dataType' => null, 'resetForm' => null, 'clearForm' => null, 'success' => 'js:' . $success, 'iframe' => true, 'forceSync' => false)); // Demo mode - no input $newForm->demo = true; // Render the form echo $newForm->renderForm($jqformparams);