public function getAdminInterface() { $st = "select ecomm_product.id as product_id, ecomm_product.name as product_name,\n\t\t\t\tecomm_product.supplier as supplier_id, ecomm_supplier.name as supplier_name, ecomm_product.price as product_price\n\t\t\t\tfrom ecomm_product left join ecomm_supplier on ecomm_product.supplier = ecomm_supplier.id\n\t\t\t\torder by ecomm_supplier.name,ecomm_product.name"; $products = Database::singleton()->query_fetch_all($st); $formPath = "/admin/EComm§ion=Plugins&page=ChangeProductPrice"; $form = new Form('change_product_prices', 'post', $formPath); if ($form->validate() && isset($_REQUEST['submit'])) { foreach ($products as $product) { $ECommProduct = new Product($product['product_id']); $ECommProduct->setPrice($_REQUEST['product_' . $product['product_id']]); $ECommProduct->save(); } return "Your products' prices have been changed successfully<br/><a href='{$formPath}'>Go back</a>"; } $oldSupplier = 0; $currentSupplier = 0; $defaultValue = array(); foreach ($products as $product) { $currentSupplier = $product['supplier_id']; if ($oldSupplier != $currentSupplier) { $form->addElement('html', '<br/><br/><hr/><h3>Supplier: ' . $product['supplier_name'] . '</h3>'); } $form->addElement('text', 'product_' . $product['product_id'], $product['product_name']); $defaultValue['product_' . $product['product_id']] = $product['product_price']; $oldSupplier = $product['supplier_id']; } $form->addElement('submit', 'submit', 'Submit'); $form->setDefaults($defaultValue); return $form->display(); }
/** * @param \Nella\Models\IEntity * @param bool * @return EntityForm */ public function setDefaults($entity, $erase = FALSE) { if ($entity instanceof \Nella\Models\IEntity) { $supportedComponents = array( 'Nette\Forms\Controls\TextBase', 'Nette\Forms\Controls\RadioList', 'Nette\Forms\Controls\Checkbox', 'Nette\Forms\Controls\Selectbox', ); $arr = array(); foreach ($this->getComponents() as $component) { foreach ($supportedComponents as $class) { if (!$component instanceof $class) { continue; } } $name = $component->getName(); $method = 'get' . ucfirst($name); if (method_exists($entity, $method)) { if ($component instanceof \Nette\Forms\Controls\Selectbox) { $value = $entity->$method(); $arr[$name] = $value ? $value->getId() : NULL; } else { $arr[$name] = $entity->$method(); } } } } else { $arr = $entity; } return parent::setDefaults($arr, $erase); }
public function actionUserChange($akce = 0, $id = -1) { $this->access($id); //kvůli Nette - action je vyhrazeno $action = $akce; $this->verifyUser(); $this->form = new AppForm($this, 'userChange'); //TODO: Definovat zprávu //$this->form->addProtection($this->formProtectedMessage); $msg = 'Heslo musí obsahovat VELKÁ a malá písmena a číslice!'; $this->form->addGroup('Přihlašovací informace'); $this->form->addText('userName', 'Uživatelské jméno:')->addRule(Form::FILLED, 'Uživatelské jméno musí být vyplněno.')->addRule(Form::MIN_LENGTH, 'Uživatelské jméno musí mít alespoň %d znaky.', 4)->addRule(Form::MAX_LENGTH, 'Uživatelské jméno může mít nejvýše %d znaků.', 20); if ($action > 0) { $this->form['userName']->setDisabled(true); } if ($action != 1) { $this->form->addPassword('password1', 'Heslo:')->addRule(Form::FILLED, 'Heslo musí být vyplněno.')->addRule(Form::MIN_LENGTH, 'Heslo musí mít alespoň %d znaků.', 8)->addRule(Form::MAX_LENGTH, 'Heslo může mít nejvýše %d znaků', 50)->addRule(Form::REGEXP, $msg, '/[A-Z]+/')->addRule(Form::REGEXP, $msg, '/[a-z]+/')->addRule(Form::REGEXP, $msg, '/[0-9]+/'); $this->form->addPassword('password2', 'Přístupové heslo (pro kontrolu):')->addRule(Form::EQUAL, 'Zadaná hesla se neshodují.', $this->form['password1']); $this->form->addText('navrhHesla', 'Navrhované heslo:'); } if ($action < 2) { $this->form->addGroup('Osobní informace'); $this->form->addText('firstName', 'Jméno:')->addRule(Form::FILLED, 'Jméno musí být vyplněno.'); $this->form->addText('surname', 'Přijmení:')->addRule(Form::FILLED, 'Přijmení musí být vyplněno.'); $this->form->addText('title', 'Titul:')->addRule(Form::MAX_LENGTH, 'Titul může mít nejvýše %d znaků.', 10); $this->form->addGroup('Kontaktní informace'); $this->form->addText('email', 'E-mail:')->addRule(Form::FILLED, 'E-mail musí být vyplněn.')->addRule(Form::EMAIL, 'Zadaný e-mail není platný.'); $this->form->addText('icq', 'ICQ:')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'ICQ musí být číslo.')->addRule(Form::MAX_LENGTH, 'ICQ může mít nejvýše %d znaků.', 10); $this->form->addText('skype', 'Skype:')->addRule(Form::MAX_LENGTH, 'Skype může mát nejvýše %d znaků.', 50); $this->form->addText('mobile', 'Mobilní telefon:')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'Mobilní telefon musí být číslo.')->addRule(Form::MAX_LENGTH, 'Mobilní telefon může mít nejvýše %d znaků.', 20); $roles = UsersModel::getRoles(); // Zobrazujeme pouze tehdy je-li uživatel administrátor - aby si uživatel sám nemohl měnit skupinu if ($this->user->isInRole('Administrator')) { $this->form->addGroup('Přístupová práva (může být vybráno více skupin)'); $this->form->addMultiSelect('prava', 'Přístupová práva:', $roles, 2); } } $this->form->onSubmit[] = array($this, 'UserFormSubmitted'); $this->form->addHidden('action')->setValue($action); if ($action > 0) { $data = UsersModel::getUser($id); $data['navrhHesla'] = UsersModel::genPass(); // Nastavíme výchozí hodnoty pro formulář $this->form->setDefaults($data); $this->form->addHidden('id')->setValue($id); $this->form->addSubmit('ok', 'Aktualizovat'); // ->onClick[] = array($this, 'OkClicked'); // nebo 'OkClickHandler' } else { $data['navrhHesla'] = UsersModel::genPass(); // Nastavíme výchozí hodnoty pro formulář $this->form->setDefaults($data); $this->form->addSubmit('ok', 'Vytvořit'); // ->onClick[] = array($this, 'OkClicked'); // nebo 'OkClickHandler' } $this->template->form = $this->form; }
private function exampleForm() { $countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'FR' => 'France', 'DE' => 'Germany', 'GR' => 'Greece', 'HU' => 'Hungary', 'IE' => 'Ireland', 'IT' => 'Italy', 'NL' => 'Netherlands', 'PL' => 'Poland', 'SK' => 'Slovakia', 'ES' => 'Spain', 'CH' => 'Switzerland', 'UA' => 'Ukraine', 'GB' => 'United Kingdom'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other'); $sex = array('m' => 'male', 'f' => 'female'); // Step 1: Define form with validation rules $form = new Form(); // group Personal data $form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.'); $form->addText('name', 'Your name:', 35)->addRule(Form::FILLED, 'Enter your name'); $form->addText('age', 'Your age:', 5)->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %.2f to %.2f', array(9.9, 100)); $form->addRadioList('gender', 'Your gender:', $sex); $form->addText('email', 'E-mail:', 35)->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address'); // ... then check email // group Shipping address $form->addGroup('Shipping address')->setOption('embedNext', TRUE); $form->addCheckbox('send', 'Ship to address')->addCondition(Form::EQUAL, TRUE)->toggle('sendBox'); // toggle div #sendBox // subgroup $form->addGroup()->setOption('container', Html::el('div')->id('sendBox')); $form->addText('street', 'Street:', 35); $form->addText('city', 'City:', 35)->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Enter your shipping address'); $form->addSelect('country', 'Country:', $countries)->skipFirst()->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Select your country'); // group Your account $form->addGroup('Your account'); $form->addPassword('password', 'Choose password:'******'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3); $form->addPassword('password2', 'Reenter password:'******'password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']); $form->addFile('avatar', 'Picture:')->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Uploaded file is not image', 'image/*'); $form->addHidden('userid'); $form->addTextArea('note', 'Comment:', 30, 5); // group for buttons $form->addGroup(); $form->addSubmit('submit1', 'Send'); // Step 2: Check if form was submitted? if ($form->isSubmitted()) { // Step 2c: Check if form is valid if ($form->isValid()) { echo '<h2>Form was submitted and successfully validated</h2>'; $values = $form->getValues(); Debug::dump($values); // this is the end, my friend :-) if (empty($disableExit)) { exit; } } } else { // not submitted, define default values $defaults = array('name' => 'John Doe', 'userid' => 231, 'country' => 'CZ'); $form->setDefaults($defaults); } return $form; }
public function getAddEditForm($target = '/admin/Campaigns§ion=addedit') { $form = new Form('campaign_addedit', 'POST', $target, '', array('class' => 'admin', 'onsubmit' => 'disableSubmit(this);')); $form->addElement('text', 'name', 'Name'); $form->addElement('select', 'auto_send', 'Auto-reminder on start', array(0 => 'Disable', 1 => 'Enable')); $date[] = $form->createElement('date', 'start_date', 'Start Date', array('format' => 'd F Y - H : i', 'addEmptyOption' => 'true', 'emptyOptionValue' => '', 'emptyOptionText' => 'Select', 'minYear' => date('Y'), 'maxYear' => date('Y') + 3), array('onchange' => 'return !updateEndDate(this)')); $date[] = $form->createElement('date', 'end_date', 'End Date', array('format' => 'd F Y - H : i', 'addEmptyOption' => 'true', 'emptyOptionValue' => '', 'emptyOptionText' => 'Select', 'minYear' => date('Y'), 'maxYear' => date('Y') + 5)); $form->addElement($date[0]); $form->addElement($date[1]); $form->addElement('tinymce', 'description', 'Description'); $form->addElement('submit', 'submit', 'Submit'); if (!is_null($this->id)) { $form->setConstants(array('campaign_id' => $this->getId())); $form->addElement('hidden', 'campaign_id'); $defaultValues['name'] = $this->getName(); $defaultValues['start_date'] = $this->getStartDate(); $defaultValues['end_date'] = $this->getEndDate(); $defaultValues['description'] = $this->getDescription(); $defaultValues['auto_send'] = $this->getAutoSend(); $form->setDefaults($defaultValues); } $form->registerRule('validDate', 'function', 'validDates', $this); //ValidDate... get it? $form->addRule(array('start_date', 'end_date'), 'Please make sure that the event has a positive length and that it begins after the current date/time', 'validDate'); $form->addRule('name', 'Please enter a campaign name', 'required'); if ($form->isSubmitted() && isset($_POST['submit'])) { if ($form->validate()) { $this->setName($form->exportValue('name')); $this->setGroup($_SESSION['authenticated_user']->getAuthGroup()); $this->setDescription($form->exportValue('description')); $this->setStartDate($this->formatDate($form->exportValue('start_date'))); $this->setEndDate($this->formatDate($form->exportValue('end_date'))); $this->setStatus($this->calcStatus()); $this->setAutoSend($form->exportValue('auto_send')); $this->save(); } } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Cart') { //Only the name will be displayed to the administrator //All the other attributes are not valid for feedstore.ca $form = new Form('CartProductType_addedit', 'post', $target); $form->setConstants(array('section' => 'product_types')); $form->addElement('hidden', 'section'); $form->setConstants(array('action' => 'addedit')); $form->addElement('hidden', 'action'); if (!is_null($this->getId())) { $form->setConstants(array('cartproducttype_type_id' => $this->getId())); $form->addElement('hidden', 'cartproducttype_type_id'); $defaultValues['cartproducttype_name'] = $this->getName(); /* $defaultValues ['cartproducttype_handler'] = $this->getHandler(); $defaultValues ['cartproducttype_masterType'] = $this->getMasterType(); $defaultValues ['cartproducttype_allow_add_to_cart'] = $this->getAllow_add_to_cart(); $defaultValues ['cartproducttype_image'] = $this->getImage()->getId(); $defaultValues ['cartproducttype_date_added'] = $this->getDate_added(); $defaultValues ['cartproducttype_last_modified'] = $this->getLast_modified(); */ $form->setDefaults($defaultValues); } $form->addElement('text', 'cartproducttype_name', 'name'); /* $form->addElement('text', 'cartproducttype_handler', 'handler'); $form->addElement('text', 'cartproducttype_masterType', 'masterType'); $form->addElement('text', 'cartproducttype_allow_add_to_cart', 'allow_add_to_cart'); $form->addElement('text', 'cartproducttype_image', 'image'); $form->addElement('text', 'cartproducttype_date_added', 'date_added'); $form->addElement('text', 'cartproducttype_last_modified', 'last_modified'); */ $form->addElement('submit', 'cartproducttype_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setName($form->exportValue('cartproducttype_name')); /* $this->setHandler($form->exportValue('cartproducttype_handler')); $this->setMasterType($form->exportValue('cartproducttype_masterType')); $this->setAllow_add_to_cart($form->exportValue('cartproducttype_allow_add_to_cart')); $this->setImage($form->exportValue('cartproducttype_image')); $this->setDate_added($form->exportValue('cartproducttype_date_added')); $this->setLast_modified($form->exportValue('cartproducttype_last_modified')); */ $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/CartOrderProduct') { $form = new Form('CartOrderProduct_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->getId())) { $form->setConstants(array('cartorderproduct_orders_products_id' => $this->getId())); $form->addElement('hidden', 'cartorderproduct_orders_products_id'); $defaultValues['cartorderproduct_orderId'] = $this->getOrderId(); $defaultValues['cartorderproduct_product'] = $this->getProduct()->getId(); $defaultValues['cartorderproduct_model'] = $this->getModel(); $defaultValues['cartorderproduct_name'] = $this->getName(); $defaultValues['cartorderproduct_price'] = $this->getPrice(); $defaultValues['cartorderproduct_finalPrice'] = $this->getFinalPrice(); $defaultValues['cartorderproduct_tax'] = $this->getTax(); $defaultValues['cartorderproduct_quantity'] = $this->getQuantity(); $defaultValues['cartorderproduct_oneTimeCharges'] = $this->getOneTimeCharges(); $defaultValues['cartorderproduct_pricedByAttribute'] = $this->getPricedByAttribute(); $defaultValues['cartorderproduct_isFree'] = $this->getIsFree(); $defaultValues['cartorderproduct_discountType'] = $this->getDiscountType(); $defaultValues['cartorderproduct_discountTypeFrom'] = $this->getDiscountTypeFrom(); $defaultValues['cartorderproduct_prid'] = $this->getPrid(); $form->setDefaults($defaultValues); } $form->addElement('text', 'cartorderproduct_orderId', 'orderId'); $form->addElement('text', 'cartorderproduct_product', 'product'); $form->addElement('text', 'cartorderproduct_model', 'model'); $form->addElement('text', 'cartorderproduct_name', 'name'); $form->addElement('text', 'cartorderproduct_price', 'price'); $form->addElement('text', 'cartorderproduct_finalPrice', 'finalPrice'); $form->addElement('text', 'cartorderproduct_tax', 'tax'); $form->addElement('text', 'cartorderproduct_quantity', 'quantity'); $form->addElement('text', 'cartorderproduct_oneTimeCharges', 'oneTimeCharges'); $form->addElement('text', 'cartorderproduct_pricedByAttribute', 'pricedByAttribute'); $form->addElement('text', 'cartorderproduct_isFree', 'isFree'); $form->addElement('text', 'cartorderproduct_discountType', 'discountType'); $form->addElement('text', 'cartorderproduct_discountTypeFrom', 'discountTypeFrom'); $form->addElement('text', 'cartorderproduct_prid', 'prid'); $form->addElement('submit', 'cartorderproduct_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setOrderId($form->exportValue('cartorderproduct_orderId')); $this->setProduct($form->exportValue('cartorderproduct_product')); $this->setModel($form->exportValue('cartorderproduct_model')); $this->setName($form->exportValue('cartorderproduct_name')); $this->setPrice($form->exportValue('cartorderproduct_price')); $this->setFinalPrice($form->exportValue('cartorderproduct_finalPrice')); $this->setTax($form->exportValue('cartorderproduct_tax')); $this->setQuantity($form->exportValue('cartorderproduct_quantity')); $this->setOneTimeCharges($form->exportValue('cartorderproduct_oneTimeCharges')); $this->setPricedByAttribute($form->exportValue('cartorderproduct_pricedByAttribute')); $this->setIsFree($form->exportValue('cartorderproduct_isFree')); $this->setDiscountType($form->exportValue('cartorderproduct_discountType')); $this->setDiscountTypeFrom($form->exportValue('cartorderproduct_discountTypeFrom')); $this->setPrid($form->exportValue('cartorderproduct_prid')); $this->save(); } return $form; }
if ($form->isSubmitted()) { // Step 2c: Check if form is valid if ($form->isValid()) { header('Content-type: text/html; charset=utf-8'); echo '<h2>Form was submitted and successfully validated</h2>'; $values = $form->getValues(); Debug::dump($values); // this is the end, my friend :-) if (empty($disableExit)) { exit; } } } else { // not submitted, define default values $defaults = array('name' => 'Žluťoučký kůň', 'userid' => 'kůň', 'note' => 'жед', 'country' => 'Česká republika'); $form->setDefaults($defaults); } // Step 3: Render form ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=<?php echo $form->encoding; ?> " /> <meta http-equiv="content-language" content="en" /> <title>Nette\Forms example 7 | Nette Framework</title> <style type="text/css">
public function getUserAddEditForm($target = '/admin/User', $admin = false) { $form = new Form('user_addedit', 'POST', $target, '', array('class' => 'admin')); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (@$_REQUEST['id']) { $user = new User($_REQUEST['id']); $form->setConstants(array('id' => $_REQUEST['id'])); $form->addElement('hidden', 'id'); } else { $user = new User(); } $statuses = array(1 => 'Active', 0 => 'Disabled'); $form->addElement('text', 'a_username', 'Username'); $form->addElement('password', 'a_password', 'Password'); $form->addElement('password', 'a_password_confirm', 'Confirm Password'); $form->addElement('text', 'a_name', 'Full Name'); $form->addElement('text', 'a_email', 'Email Address'); if ($admin) { $form->addElement('select', 'a_status', 'Active Status', $statuses); } if (isset($this->user) && $this->user->hasPerm('assigngroups')) { $sql = 'SELECT agp_id, agp_name from auth_groups'; $groups = Database::singleton()->query_fetch_all($sql); $assignableGroup = array(); foreach ($groups as $group) { $assignableGroup[$group['agp_id']] = $group['agp_name']; } if (@$user) { $defaultValues['a_group'] = $user->getAuthGroup(); } $form->addElement('select', 'a_group', 'Member Group', $assignableGroup); } $form->addElement('submit', 'a_submit', 'Save'); $defaultValues['a_username'] = $user->getUsername(); $defaultValues['a_name'] = $user->getName(); $defaultValues['a_email'] = $user->getEmail(); $defaultValues['a_password'] = null; $defaultValues['a_password_confirm'] = null; if ($admin) { $defaultValues['a_status'] = $user->getActiveStatus(); } $form->setDefaults($defaultValues); $form->addRule('a_username', 'Please enter a username', 'required', null); $form->addRule('a_name', 'Please enter the user\'s name', 'required', null); $form->addRule('a_email', 'Please enter an email address', 'required', null); $form->addRule('a_email', 'Please enter a valid email address', 'email', null); if (!isset($_REQUEST['id'])) { $form->addRule('a_password', 'Please enter a password', 'required', null); $form->addRule('a_password_confirm', 'Please confirm the passwords match', 'required', null); } $form->addRule(array('a_password', 'a_password_confirm'), 'The passwords do not match', 'compare', null); if (isset($_REQUEST['a_submit']) && $form->validate()) { $this->template = 'admin/user.tpl'; $this->doUserSubmit(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/CartOrderProductAttribute') { $form = new Form('CartOrderProductAttribute_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->getId())) { $form->setConstants(array('cartorderproductattribute_orders_products_attributes_id' => $this->getId())); $form->addElement('hidden', 'cartorderproductattribute_orders_products_attributes_id'); $defaultValues['cartorderproductattribute_orderid'] = $this->getOrderid(); $defaultValues['cartorderproductattribute_productid'] = $this->getProductid(); $defaultValues['cartorderproductattribute_products_options'] = $this->getProducts_options(); $defaultValues['cartorderproductattribute_products_options_values'] = $this->getProducts_options_values(); $defaultValues['cartorderproductattribute_options_values_price'] = $this->getOptions_values_price(); $defaultValues['cartorderproductattribute_price_prefix'] = $this->getPrice_prefix(); $defaultValues['cartorderproductattribute_product_attribute_is_free'] = $this->getProduct_attribute_is_free(); $defaultValues['cartorderproductattribute_products_attributes_weight'] = $this->getProducts_attributes_weight(); $defaultValues['cartorderproductattribute_products_attributes_weight_prefix'] = $this->getProducts_attributes_weight_prefix(); $defaultValues['cartorderproductattribute_attributes_discounted'] = $this->getAttributes_discounted(); $defaultValues['cartorderproductattribute_attributes_price_base_included'] = $this->getAttributes_price_base_included(); $defaultValues['cartorderproductattribute_attributes_price_onetime'] = $this->getAttributes_price_onetime(); $defaultValues['cartorderproductattribute_attributes_price_factor'] = $this->getAttributes_price_factor(); $defaultValues['cartorderproductattribute_attributes_price_factor_offset'] = $this->getAttributes_price_factor_offset(); $defaultValues['cartorderproductattribute_attributes_price_factor_onetime'] = $this->getAttributes_price_factor_onetime(); $defaultValues['cartorderproductattribute_attributes_price_factor_onetime_offset'] = $this->getAttributes_price_factor_onetime_offset(); $defaultValues['cartorderproductattribute_attributes_qty_prices'] = $this->getAttributes_qty_prices(); $defaultValues['cartorderproductattribute_attributes_qty_prices_onetime'] = $this->getAttributes_qty_prices_onetime(); $defaultValues['cartorderproductattribute_attributes_price_words'] = $this->getAttributes_price_words(); $defaultValues['cartorderproductattribute_attributes_price_words_free'] = $this->getAttributes_price_words_free(); $defaultValues['cartorderproductattribute_attributes_price_letters'] = $this->getAttributes_price_letters(); $defaultValues['cartorderproductattribute_attributes_price_letters_free'] = $this->getAttributes_price_letters_free(); $defaultValues['cartorderproductattribute_products_options_id'] = $this->getProducts_options_id(); $defaultValues['cartorderproductattribute_products_options_values_id'] = $this->getProducts_options_values_id(); $defaultValues['cartorderproductattribute_products_prid'] = $this->getProducts_prid(); $form->setDefaults($defaultValues); } $form->addElement('text', 'cartorderproductattribute_orderid', 'orderid'); $form->addElement('text', 'cartorderproductattribute_productid', 'productid'); $form->addElement('text', 'cartorderproductattribute_products_options', 'products_options'); $form->addElement('text', 'cartorderproductattribute_products_options_values', 'products_options_values'); $form->addElement('text', 'cartorderproductattribute_options_values_price', 'options_values_price'); $form->addElement('text', 'cartorderproductattribute_price_prefix', 'price_prefix'); $form->addElement('text', 'cartorderproductattribute_product_attribute_is_free', 'product_attribute_is_free'); $form->addElement('text', 'cartorderproductattribute_products_attributes_weight', 'products_attributes_weight'); $form->addElement('text', 'cartorderproductattribute_products_attributes_weight_prefix', 'products_attributes_weight_prefix'); $form->addElement('text', 'cartorderproductattribute_attributes_discounted', 'attributes_discounted'); $form->addElement('text', 'cartorderproductattribute_attributes_price_base_included', 'attributes_price_base_included'); $form->addElement('text', 'cartorderproductattribute_attributes_price_onetime', 'attributes_price_onetime'); $form->addElement('text', 'cartorderproductattribute_attributes_price_factor', 'attributes_price_factor'); $form->addElement('text', 'cartorderproductattribute_attributes_price_factor_offset', 'attributes_price_factor_offset'); $form->addElement('text', 'cartorderproductattribute_attributes_price_factor_onetime', 'attributes_price_factor_onetime'); $form->addElement('text', 'cartorderproductattribute_attributes_price_factor_onetime_offset', 'attributes_price_factor_onetime_offset'); $form->addElement('text', 'cartorderproductattribute_attributes_qty_prices', 'attributes_qty_prices'); $form->addElement('text', 'cartorderproductattribute_attributes_qty_prices_onetime', 'attributes_qty_prices_onetime'); $form->addElement('text', 'cartorderproductattribute_attributes_price_words', 'attributes_price_words'); $form->addElement('text', 'cartorderproductattribute_attributes_price_words_free', 'attributes_price_words_free'); $form->addElement('text', 'cartorderproductattribute_attributes_price_letters', 'attributes_price_letters'); $form->addElement('text', 'cartorderproductattribute_attributes_price_letters_free', 'attributes_price_letters_free'); $form->addElement('text', 'cartorderproductattribute_products_options_id', 'products_options_id'); $form->addElement('text', 'cartorderproductattribute_products_options_values_id', 'products_options_values_id'); $form->addElement('text', 'cartorderproductattribute_products_prid', 'products_prid'); $form->addElement('submit', 'cartorderproductattribute_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setOrderid($form->exportValue('cartorderproductattribute_orderid')); $this->setProductid($form->exportValue('cartorderproductattribute_productid')); $this->setProducts_options($form->exportValue('cartorderproductattribute_products_options')); $this->setProducts_options_values($form->exportValue('cartorderproductattribute_products_options_values')); $this->setOptions_values_price($form->exportValue('cartorderproductattribute_options_values_price')); $this->setPrice_prefix($form->exportValue('cartorderproductattribute_price_prefix')); $this->setProduct_attribute_is_free($form->exportValue('cartorderproductattribute_product_attribute_is_free')); $this->setProducts_attributes_weight($form->exportValue('cartorderproductattribute_products_attributes_weight')); $this->setProducts_attributes_weight_prefix($form->exportValue('cartorderproductattribute_products_attributes_weight_prefix')); $this->setAttributes_discounted($form->exportValue('cartorderproductattribute_attributes_discounted')); $this->setAttributes_price_base_included($form->exportValue('cartorderproductattribute_attributes_price_base_included')); $this->setAttributes_price_onetime($form->exportValue('cartorderproductattribute_attributes_price_onetime')); $this->setAttributes_price_factor($form->exportValue('cartorderproductattribute_attributes_price_factor')); $this->setAttributes_price_factor_offset($form->exportValue('cartorderproductattribute_attributes_price_factor_offset')); $this->setAttributes_price_factor_onetime($form->exportValue('cartorderproductattribute_attributes_price_factor_onetime')); $this->setAttributes_price_factor_onetime_offset($form->exportValue('cartorderproductattribute_attributes_price_factor_onetime_offset')); $this->setAttributes_qty_prices($form->exportValue('cartorderproductattribute_attributes_qty_prices')); $this->setAttributes_qty_prices_onetime($form->exportValue('cartorderproductattribute_attributes_qty_prices_onetime')); $this->setAttributes_price_words($form->exportValue('cartorderproductattribute_attributes_price_words')); $this->setAttributes_price_words_free($form->exportValue('cartorderproductattribute_attributes_price_words_free')); $this->setAttributes_price_letters($form->exportValue('cartorderproductattribute_attributes_price_letters')); $this->setAttributes_price_letters_free($form->exportValue('cartorderproductattribute_attributes_price_letters_free')); $this->setProducts_options_id($form->exportValue('cartorderproductattribute_products_options_id')); $this->setProducts_options_values_id($form->exportValue('cartorderproductattribute_products_options_values_id')); $this->setProducts_prid($form->exportValue('cartorderproductattribute_products_prid')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/InstantMessage') { $form = new Form('InstantMessage_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->id)) { $form->setConstants(array('instantmessage_id' => $this->getId())); $form->addElement('hidden', 'instantmessage_id'); $defaultValues['instantmessage_from'] = $this->getFrom()->getId(); $defaultValues['instantmessage_to'] = $this->getTo()->getId(); $defaultValues['instantmessage_namespace'] = $this->getNamespace(); $defaultValues['instantmessage_thread'] = $this->getThread(); $defaultValues['instantmessage_message'] = $this->getMessage(); $defaultValues['instantmessage_read'] = $this->getRead(); $defaultValues['instantmessage_timestamp'] = $this->getTimestamp(); $form->setDefaults($defaultValues); } $form->addElement('text', 'instantmessage_from', 'from /* Fill in text */'); $form->addElement('text', 'instantmessage_to', 'to /* Fill in text */'); $form->addElement('text', 'instantmessage_namespace', 'namespace /* Fill in text */'); $form->addElement('text', 'instantmessage_thread', 'thread /* Fill in text */'); $form->addElement('text', 'instantmessage_message', 'message /* Fill in text */'); $form->addElement('text', 'instantmessage_read', 'read /* Fill in text */'); $form->addElement('text', 'instantmessage_timestamp', 'timestamp /* Fill in text */'); $form->addElement('submit', 'instantmessage_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setFrom($form->exportValue('instantmessage_from')); $this->setTo($form->exportValue('instantmessage_to')); $this->setNamespace($form->exportValue('instantmessage_namespace')); $this->setThread($form->exportValue('instantmessage_thread')); $this->setMessage($form->exportValue('instantmessage_message')); $this->setRead($form->exportValue('instantmessage_read')); $this->setTimestamp($form->exportValue('instantmessage_timestamp')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Cart') { $form = new Form('CartShippingRate_addedit', 'post', $target); $form->setConstants(array('section' => 'shipping')); $form->addElement('hidden', 'section'); $form->setConstants(array('action' => 'addedit')); $form->addElement('hidden', 'action'); if (!is_null($this->getId())) { $form->setConstants(array('cartshippingrate_id' => $this->getId())); $form->addElement('hidden', 'cartshippingrate_id'); $defaultValues['cartshippingrate_state'] = $this->getState(); $defaultValues['cartshippingrate_country'] = $this->getCountry(); $defaultValues['cartshippingrate_cost'] = $this->getCost(); $form->setDefaults($defaultValues); } $countrySelect = array('onchange' => 'selectCountry();', 'id' => 'cartshippingrate_country'); $form->addElement('select', 'cartshippingrate_country', 'Country', Form::getCountryArray(), $countrySelect); $form->addElement('select', 'cartshippingrate_state', 'Province/State', Form::getStatesArray("Canada")); $form->addElement('text', 'cartshippingrate_cost', 'Shipping Cost'); $form->addElement('submit', 'cartshippingrate_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $selectedCountry = $form->exportValue('cartshippingrate_country'); //Only if the selected country is Canada, insert the selected state. if (CartShippingRate::hasState($selectedCountry)) { $selectedState = $form->exportValue('cartshippingrate_state'); } else { $selectedState = 0; } $this->setCountry($selectedCountry); $this->setState($selectedState); $this->setCost($form->exportValue('cartshippingrate_cost')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/CartSpecial') { $form = new Form('CartSpecial_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->getId())) { $form->setConstants(array('cartspecial_specials_id' => $this->getId())); $form->addElement('hidden', 'cartspecial_specials_id'); $defaultValues['cartspecial_product'] = $this->getProduct(); $defaultValues['cartspecial_new_products_price'] = $this->getNew_products_price(); $defaultValues['cartspecial_date_added'] = $this->getDate_added(); $defaultValues['cartspecial_last_modified'] = $this->getLast_modified(); $defaultValues['cartspecial_expires_date'] = $this->getExpires_date(); $defaultValues['cartspecial_date_status_change'] = $this->getDate_status_change(); $defaultValues['cartspecial_status'] = $this->getStatus(); $defaultValues['cartspecial_date_available'] = $this->getDate_available(); $form->setDefaults($defaultValues); } $form->addElement('text', 'cartspecial_product', 'product'); $form->addElement('text', 'cartspecial_new_products_price', 'new_products_price'); $form->addElement('text', 'cartspecial_date_added', 'date_added'); $form->addElement('text', 'cartspecial_last_modified', 'last_modified'); $form->addElement('text', 'cartspecial_expires_date', 'expires_date'); $form->addElement('text', 'cartspecial_date_status_change', 'date_status_change'); $form->addElement('text', 'cartspecial_status', 'status'); $form->addElement('text', 'cartspecial_date_available', 'date_available'); $form->addElement('submit', 'cartspecial_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setProduct($form->exportValue('cartspecial_product')); $this->setNew_products_price($form->exportValue('cartspecial_new_products_price')); $this->setDate_added($form->exportValue('cartspecial_date_added')); $this->setLast_modified($form->exportValue('cartspecial_last_modified')); $this->setExpires_date($form->exportValue('cartspecial_expires_date')); $this->setDate_status_change($form->exportValue('cartspecial_date_status_change')); $this->setStatus($form->exportValue('cartspecial_status')); $this->setDate_available($form->exportValue('cartspecial_date_available')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Content') { $form = new Form('ContentTemplate_addedit', 'post', $target); $form->setConstants(array('section' => 'templates')); $form->addElement('hidden', 'section'); if (!is_null($this->id)) { $form->setConstants(array('contenttemplate_id' => $this->getId())); $form->addElement('hidden', 'contenttemplate_id'); $defaultValues['contenttemplate_name'] = $this->getName(); $defaultValues['contenttemplate_description'] = $this->getDescription(); $defaultValues['contenttemplate_content'] = $this->getContent(); $defaultValues['contenttemplate_preview_image'] = $this->getPreview_image(); $form->setDefaults($defaultValues); } $form->addElement('text', 'contenttemplate_name', 'name /* Fill in text */'); $form->addElement('text', 'contenttemplate_description', 'description /* Fill in text */'); $form->addElement('text', 'contenttemplate_content', 'content /* Fill in text */'); $form->addElement('text', 'contenttemplate_preview_image', 'preview_image /* Fill in text */'); $form->addElement('submit', 'contenttemplate_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setName($form->exportValue('contenttemplate_name')); $this->setDescription($form->exportValue('contenttemplate_description')); $this->setContent($form->exportValue('contenttemplate_content')); $this->setPreview_image($form->exportValue('contenttemplate_preview_image')); $this->save(); } return $form; }
public function getAddEditForm($target = '/admin/DMS') { $form = new Form('DataStorage_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->id)) { $form->setConstants(array('datastorage_id' => $this->getId())); $form->addElement('hidden', 'datastorage_id'); //$defaultValues ['datastorage_tags'] = $this->getTags(); $defaultValues['datastorage_description'] = $this->getDescription(); $form->setDefaults($defaultValues); } $fupload = $form->addElement('file', 'datastorage_file', 'File'); //$form->addElement('select', 'datastorage_tags', 'Tags', array('sdf', 'sdfsdf')); $form->addElement('textarea', 'datastorage_description', 'Description'); $form->addElement('submit', 'datastorage_submit', 'Submit'); if (is_null($this->id)) { $form->addRule('datastorage_file', 'Please upload a file', 'uploadedfile'); } if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['datastorage_submit'])) { //$this->setTags(trim($form->exportValue('datastorage_tags'))); $this->setDescription($_REQUEST['datastorage_description']); if ($fupload->isUploadedFile() && isset($_FILES['datastorage_file'])) { $this->insert($_FILES['datastorage_file']); } $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Cart') { $form = new Form('CartTaxRate_addedit', 'post', $target); $form->setConstants(array('section' => 'tax_rates')); $form->addElement('hidden', 'section'); $form->setConstants(array('action' => 'addedit')); $form->addElement('hidden', 'action'); if (!is_null($this->getId())) { $form->setConstants(array('carttaxrate_tax_rates_id' => $this->getId())); $form->addElement('hidden', 'carttaxrate_tax_rates_id'); $defaultValues['carttaxrate_zone'] = $this->getZone(); $defaultValues['carttaxrate_taxClass'] = $this->getTaxClass()->getId(); //$defaultValues ['carttaxrate_tax_priority'] = $this->getTax_priority(); $defaultValues['carttaxrate_rate'] = $this->getRate(); $defaultValues['carttaxrate_description'] = $this->getDescription(); //$defaultValues ['carttaxrate_last_modified'] = $this->getLast_modified(); //$defaultValues ['carttaxrate_date_added'] = $this->getDate_added(); $form->setDefaults($defaultValues); } $form->addElement('select', 'carttaxrate_zone', 'Zone', Form::getStatesArray()); $form->addElement('select', 'carttaxrate_taxClass', 'Tax Class', CartTaxClass::toArray()); //$form->addElement('text', 'carttaxrate_tax_priority', 'tax_priority'); $form->addElement('text', 'carttaxrate_rate', 'Tax Rate (%)'); $form->addElement('text', 'carttaxrate_description', 'Description'); //$form->addElement('text', 'carttaxrate_last_modified', 'last_modified'); //$form->addElement('text', 'carttaxrate_date_added', 'date_added'); $form->addElement('submit', 'carttaxrate_submit', 'Submit'); $form->addRule('carttaxrate_rate', 'Please enter a Tax Rate', 'required', null); $form->addRule('carttaxrate_description', 'Please enter a Description', 'required', null); if ($form->validate() && $form->isSubmitted()) { $this->setZone($form->exportValue('carttaxrate_zone')); $this->setTaxClass($form->exportValue('carttaxrate_taxClass')); //$this->setTax_priority($form->exportValue('carttaxrate_tax_priority')); $this->setRate($form->exportValue('carttaxrate_rate')); $this->setDescription($form->exportValue('carttaxrate_description')); //$this->setLast_modified($form->exportValue('carttaxrate_last_modified')); //$this->setDate_added($form->exportValue('carttaxrate_date_added')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Mail') { $form = new Form('MailContent_addedit', 'post', $target); $form->setConstants(array('section' => 'content')); $form->addElement('hidden', 'section'); $form->setConstants(array('action' => 'addedit')); $form->addElement('hidden', 'action'); if (!is_null($this->getId())) { $form->setConstants(array('mailcontent_mail_id' => $this->getId())); $form->addElement('hidden', 'mailcontent_mail_id'); $defaultValues['mailcontent_subject'] = $this->getSubject(); $defaultValues['mailcontent_content'] = $this->getContent(); //$defaultValues ['mailcontent_lastMod'] = $this->getLastMod(); $defaultValues['mailcontent_fromName'] = $this->getFromName(); $defaultValues['mailcontent_fromAddress'] = $this->getFromAddress(); $form->setDefaults($defaultValues); } $form->addElement('text', 'mailcontent_subject', 'Mail Subject Line'); $form->addElement('text', 'mailcontent_fromName', 'From Name'); $form->addElement('text', 'mailcontent_fromAddress', 'From Address'); $form->addElement('tinymce', 'mailcontent_content', 'Mail Content', array('style' => 'width: 100px;')); //$form->addElement('text', 'mailcontent_lastMod', 'Last Modified'); $form->addElement('submit', 'mailcontent_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setSubject($form->exportValue('mailcontent_subject')); $this->setContent($form->exportValue('mailcontent_content')); //$this->setLastMod($form->exportValue('mailcontent_lastMod')); $this->setFromName($form->exportValue('mailcontent_fromName')); $this->setFromAddress($form->exportValue('mailcontent_fromAddress')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/CartProductOptionValue') { $form = new Form('CartProductOptionValue_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->get())) { $form->setConstants(array('cartproductoptionvalue_id' => $this->getId())); $form->addElement('hidden', 'cartproductoptionvalue_id'); $defaultValues['cartproductoptionvalue_language_id'] = $this->getLanguage_id(); $defaultValues['cartproductoptionvalue_name'] = $this->getName(); $defaultValues['cartproductoptionvalue_sort'] = $this->getSort(); $form->setDefaults($defaultValues); } $form->addElement('text', 'cartproductoptionvalue_id', 'id'); $form->addElement('text', 'cartproductoptionvalue_name', 'name'); $form->addElement('text', 'cartproductoptionvalue_sort', 'sort'); $form->addElement('submit', 'cartproductoptionvalue_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setLanguage_id($form->exportValue('cartproductoptionvalue_language_id')); $this->setName($form->exportValue('cartproductoptionvalue_name')); $this->setSort($form->exportValue('cartproductoptionvalue_sort')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Cart') { $form = new Form('CartProductOption_addedit', 'post', $target); $form->setConstants(array('section' => 'attributes')); $form->addElement('hidden', 'section'); $form->setConstants(array('action' => 'addedit')); $form->addElement('hidden', 'action'); if (!is_null($this->getId())) { $form->setConstants(array('cartproductoption_id' => $this->getId())); $form->addElement('hidden', 'cartproductoption_id'); $defaultValues['cartproductoption_language_id'] = $this->getLanguageId(); $defaultValues['cartproductoption_name'] = $this->getName(); $defaultValues['cartproductoption_sort'] = $this->getSort(); $defaultValues['cartproductoption_type'] = $this->getType(); $defaultValues['cartproductoption_length'] = $this->getLength(); $defaultValues['cartproductoption_comment'] = $this->getComment(); $defaultValues['cartproductoption_size'] = $this->getSize(); $defaultValues['cartproductoption_imagesPerRow'] = $this->getImagesPerRow(); $defaultValues['cartproductoption_imagesStyle'] = $this->getImagesStyle(); $defaultValues['cartproductoption_rows'] = $this->getRows(); $form->setDefaults($defaultValues); } $form->addElement('text', 'cartproductoption_name', 'Name'); $form->addElement('text', 'cartproductoption_comment', 'Comment'); $form->addElement('submit', 'cartproductoption_submit', 'Submit'); if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['cartproductoption_submit'])) { $this->setName($form->exportValue('cartproductoption_name')); $this->setComment($form->exportValue('cartproductoption_comment')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/MailQueue') { $form = new Form('MailQueue_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->getId())) { $form->setConstants(array('mailqueue_id' => $this->getId())); $form->addElement('hidden', 'mailqueue_id'); $defaultValues['mailqueue_sendOut'] = $this->getSendOut(); $defaultValues['mailqueue_user'] = $this->getUser(); $form->setDefaults($defaultValues); } $form->addElement('text', 'mailqueue_sendOut', 'sendOut'); $form->addElement('text', 'mailqueue_user', 'user'); $form->addElement('submit', 'mailqueue_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setSendOut($form->exportValue('mailqueue_sendOut')); $this->setUser($form->exportValue('mailqueue_user')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Mail') { $form = new Form('MailUser_addedit', 'post', $target); $form->setConstants(array('section' => 'users')); $form->addElement('hidden', 'section'); $form->setConstants(array('action' => 'addedit')); $form->addElement('hidden', 'action'); if (!is_null($this->getId())) { $form->setConstants(array('mailuser_id' => $this->getId())); $form->addElement('hidden', 'mailuser_id'); $defaultValues['mailuser_email'] = $this->getEmail(); $defaultValues['mailuser_firstName'] = $this->getFirstName(); $defaultValues['mailuser_lastName'] = $this->getLastName(); $defaultValues['mailuser_notes'] = $this->getNotes(); $form->setDefaults($defaultValues); } $form->addElement('text', 'mailuser_email', 'E-Mail Address'); $form->addElement('text', 'mailuser_firstName', 'First Name'); $form->addElement('text', 'mailuser_lastName', 'Last Name'); $form->addElement('tinymce', 'mailuser_notes', 'Notes'); $form->addElement('submit', 'mailuser_submit', 'Save'); if ($form->validate() && $form->isSubmitted()) { $this->setEmail($form->exportValue('mailuser_email')); $this->setFirstName($form->exportValue('mailuser_firstName')); $this->setLastName($form->exportValue('mailuser_lastName')); $this->setNotes($form->exportValue('mailuser_notes')); $this->save(); } return $form; }
public static function getAddEditForm($target = '/admin/User') { $form = new Form('group_addedit', 'POST', $target, '', array('class' => 'admin')); if (@$_REQUEST['id']) { $group = new Group($_REQUEST['id']); $form->setConstants(array('id' => $_REQUEST['id'])); $form->addElement('hidden', 'id'); } else { $group = new Group(); } $form->setConstants(array('section' => 'groupsaddedit')); $form->addElement('hidden', 'section'); $form->addElement('text', 'name', 'Group Name'); $form->addElement('submit', 'submit', 'Save'); $form->addElement('reset', 'cancel', 'Cancel'); $defaultValues['name'] = $group->getName(); $form->setDefaults($defaultValues); if ($form->validate() && isset($_REQUEST['submit'])) { $group->setName($_REQUEST['name']); $group->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Analytics') { $form = new Form('analytics_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->getId())) { $form->setConstants(array('analytics_id' => $this->getId())); $form->addElement('hidden', 'analytics_id'); $defaultValues['analytics_content'] = $this->getContent(); $defaultValues['analytics_timestamp'] = $this->getTimestamp(); $form->setDefaults($defaultValues); } $form->addElement('html', '<br /><span style="color:red; padding-left:125px;">Paste your code below</span>'); $form->addElement('textarea', 'analytics_content', 'content', array('rows' => 15, 'cols' => 80)); //$form->addElement('text', 'analytics_timestamp', 'timestamp'); $form->addElement('submit', 'analytics_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setContent($form->exportValue('analytics_content')); $this->setTimestamp($form->exportValue('analytics_timestamp')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Cart') { $form = new Form('CartTaxClass_addedit', 'post', $target); $form->setConstants(array('section' => 'tax_classes')); $form->addElement('hidden', 'section'); $form->setConstants(array('action' => 'addedit')); $form->addElement('hidden', 'action'); if (!is_null($this->getId())) { $form->setConstants(array('carttaxclass_tax_class_id' => $this->getId())); $form->addElement('hidden', 'carttaxclass_tax_class_id'); $defaultValues['carttaxclass_title'] = $this->getTitle(); $defaultValues['carttaxclass_description'] = $this->getDescription(); $defaultValues['carttaxclass_last_modified'] = $this->getLast_modified(); $defaultValues['carttaxclass_date_added'] = $this->getDate_added(); $form->setDefaults($defaultValues); } $form->addElement('text', 'carttaxclass_title', 'Title'); $text = $form->addElement('textarea', 'carttaxclass_description', 'Description'); $text->setCols(60); $text->setRows(10); $form->addElement('text', 'carttaxclass_last_modified', 'Last Modified'); $form->addElement('text', 'carttaxclass_date_added', 'Date Added'); $form->addElement('submit', 'carttaxclass_submit', 'Submit'); $form->addRule('carttaxclass_title', 'Please enter a Title', 'required', null); $form->addRule('carttaxclass_description', 'Please enter a Description', 'required', null); if ($form->validate() && $form->isSubmitted()) { $this->setTitle($form->exportValue('carttaxclass_title')); $this->setDescription($form->exportValue('carttaxclass_description')); $this->setLast_modified($form->exportValue('carttaxclass_last_modified')); $this->setDate_added($form->exportValue('carttaxclass_date_added')); $this->save(); } return $form; }
public function getAddEditForm($name = "") { $form = new Form('address_addedit' . $name, 'post'); if (!is_null($this->id)) { //$post = new Address($_REQUEST['address_id']); $form->setConstants(array('address_id' => $this->getId())); $form->addElement('hidden', 'address_id'); } $defaults['address'] = $this->getStreetAddress(); $defaults['city'] = $this->getCity(); $defaults['state'] = $this->getState(); $defaults['country'] = $this->getCountry(); $defaults['postalcode'] = $this->getPostalCode(); $form->setDefaults($defaults); $form->addElement('text', 'address', 'Address'); $form->addElement('text', 'city', 'City/ Town'); $form->addElement('text', 'postalcode', 'Postal Code'); $form->setConstants(array('state' => '1')); //31 is the ID of Alberta $form->addElement('hidden', 'state'); $form->addElement('static', 'state1', 'State / Province', 'Alberta'); $form->setConstants(array('country' => '31')); //31 is the ID of Canada $form->addElement('hidden', 'country'); $form->addElement('static', 'country1', 'Country', 'Canada'); if ($form->validate() && isset($_REQUEST['submit'])) { //if (isset($_REQUEST['address_id'])) { // $address = new Address($_REQUEST['address_id']); //} else { // $address = new Address(); //} $this->setCity($_REQUEST['city']); $this->setStreetAddress($_REQUEST['address']); $this->setPostalCode($_REQUEST['postalcode']); $this->setState($_REQUEST['state']); $this->setCountry($_REQUEST['country']); $this->doGeocode(); $this->save(); } return $form; }
public function getAddToCartForm() { $form = new Form('product_addtocart', 'post', '/store/cart/', null, array('onchange' => 'updateProduct(this);')); $form->setConstants(array('action' => 'add')); $form->addElement('hidden', 'action'); $form->setConstants(array('productId' => $this->getId())); $form->addElement('hidden', 'productId'); $defaults['productQuantity'] = $this->getOrderMin(); $defaults['productPalletCount'] = $this->getPalletCount(); $price = $this->getFinalPrice(); $atts = $this->getAttributes(); if (isset($_REQUEST['productQuantity'])) { $price *= $_REQUEST['productQuantity']; } else { $price *= $this->getOrderMin(); } $opts = $this->getOptions(); $types = array(); foreach ($opts as $opt) { $types[$opt->getOptionsId()->getId()][] = $opt; } foreach ($types as $key => $atts) { $attributes_elements = array(); if (isset($_REQUEST['att'][$key])) { $setopt = new CartProductAttribute($_REQUEST['att'][$key]); $price += $setopt->getValuesPrice(); } } //$form->addElement('image', 'buy', '/modules/Cart/images/buyBtn.jpg'); $form->addElement('html', '<h3 class="productPrice">$' . $price . '</h3>'); foreach ($types as $key => $atts) { $attributes_elements = array(); foreach ($atts as $att) { if ($att->getInventory() <= 0) { continue; } $attributes_elements[$att->getId()] = $att->getValue()->getName(); //$form->createElement('select', $att->getOptionsId()->getName(), array()); } if (count($attributes_elements) > 0) { $form->addElement('select', 'att[' . $key . ']', $att->getOptionsId()->getName(), $attributes_elements); } } /* $attributes_elements = array(); foreach ($atts as &$att) { $array = array(); foreach ($att as $option) { $array[$option->getValue()->getId()] = $option->getValue()->getName(); } $attributes_elements[] = $form->createElement('select', $att[0]->getOptionsId()->getId(), $att[0]->getOptionsId()->getName(), $array); if (isset($_REQUEST['att'])) { $attribute = new CartProductAttribute($_REQUEST['att'][$att[0]->getOptionsId()->getId()]); $price += $attribute->getValuesPrice(); } } if ($atts) $form->addGroup($attributes_elements,'att',$attribute->getOptionsId()->getName(),' '); */ $form->setDefaults($defaults); $qty = array(); for ($i = $this->getOrderMin(); $i < $this->getOrderMin() + 99; $i++) { $qty[$i] = $i; } $form->addElement('select', 'productQuantity', 'Quantity', $qty); $form->addElement('html', '<div class="element"><input id="buy" name="buy" type="image" src="/modules/Cart/images/addToCart.jpg" /></div><br /><br />'); return $form; }
public function getAddEditForm($target = '/admin/Menu') { require_once 'Menu.php'; if (isset($_REQUEST['id'])) { $item = new MenuItem($_REQUEST['id']); } $status = array('active' => 'Active', 'disabled' => 'Disabled'); $defaultValues['status'] = @array($item->status); $menu = new Menu(); $parent = $menu->toArray(); $defaultValues['parent'] = @array($item->parent); $form = new Form('menu_addedit', 'POST', $target, '', array('class' => 'admin')); if (@$item) { $form->setConstants(array('id' => $item->getId(), 'section' => 'addedit')); $form->addElement('hidden', 'id'); $links = $menu->getLinkables($item->module_id); } else { $form->setConstants(array('section' => 'addedit')); } $form->addElement('hidden', 'section'); $form->addElement('text', 'display', 'Display Name', array('value' => @$item->display)); $active = Config::getActiveModules(); $linkableType = array(); foreach ($active as $module) { $modulename = 'Module_' . $module['module']; include_once SITE_ROOT . '/modules/' . $module['module'] . '/' . $module['module'] . '.php'; $obj = new $modulename(); $test = new ReflectionClass($modulename); if ($test->hasMethod('getValidLinks')) { $linkableType[$module['id']] = $obj->linkType(); } } if (@(!$item)) { $keys = array_keys($linkableType); $links = $menu->getLinkables($keys[0]); } $defaultValues['link'] = @array($item->link_id); $defaultValues['linktype'] = @array($item->module_id); $defaultValues['target'] = @array($item->target); $form->addElement('select', 'status', 'Status', $status); $form->addElement('select', 'linktype', 'Link Type', $linkableType); $form->addElement('select', 'link', 'Link To', $links); $form->addElement('select', 'target', 'Open In', array('same' => 'Same Window', 'new' => 'New Window')); $form->addElement('select', 'parent', 'Parent Item', $parent); $form->addElement('submit', 'submit', 'Save'); $form->applyFilter('display', 'trim'); $form->addRule('display', 'Please enter a display name', 'required', null, 'client'); $form->addRule('parent', 'Please choose a parent', 'required', null, 'client'); $form->addRule('linktype', 'Please choose a link type', 'required', null, 'client'); $form->addRule('link', 'Please choose a link page', 'required', null, 'client'); $form->addRule('target', 'Please choose a target', 'required', null, 'client'); $form->addRule('status', 'Please choose a status', 'required', null, 'client'); $form->setDefaults($defaultValues); if (isset($_REQUEST['submit']) && $form->validate()) { $this->template = 'admin/menu.tpl'; $this->doMenuSubmit(); return false; } else { if (isset($_REQUEST['submit'])) { $formArray['errors'] = $form->_errors; } } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/CartBasketAttribute') { $form = new Form('CartBasketAttribute_addedit', 'post', $target); $form->setConstants(array('section' => 'addedit')); $form->addElement('hidden', 'section'); if (!is_null($this->getId())) { $form->setConstants(array('cartbasketattribute_customers_basket_attributes_id' => $this->getId())); $form->addElement('hidden', 'cartbasketattribute_customers_basket_attributes_id'); $defaultValues['cartbasketattribute_user'] = $this->getUser()->getId(); $defaultValues['cartbasketattribute_product'] = $this->getProduct(); $defaultValues['cartbasketattribute_optionsId'] = $this->getOptionsId(); $defaultValues['cartbasketattribute_valueId'] = $this->getValueId(); $defaultValues['cartbasketattribute_valueText'] = $this->getValueText(); $defaultValues['cartbasketattribute_sort'] = $this->getSort(); $form->setDefaults($defaultValues); } $form->addElement('text', 'cartbasketattribute_user', 'user'); $form->addElement('text', 'cartbasketattribute_product', 'product'); $form->addElement('text', 'cartbasketattribute_optionsId', 'optionsId'); $form->addElement('text', 'cartbasketattribute_valueId', 'valueId'); $form->addElement('text', 'cartbasketattribute_valueText', 'valueText'); $form->addElement('text', 'cartbasketattribute_sort', 'sort'); $form->addElement('submit', 'cartbasketattribute_submit', 'Submit'); if ($form->validate() && $form->isSubmitted()) { $this->setUser($form->exportValue('cartbasketattribute_user')); $this->setProduct($form->exportValue('cartbasketattribute_product')); $this->setOptionsId($form->exportValue('cartbasketattribute_optionsId')); $this->setValueId($form->exportValue('cartbasketattribute_valueId')); $this->setValueText($form->exportValue('cartbasketattribute_valueText')); $this->setSort($form->exportValue('cartbasketattribute_sort')); $this->save(); } return $form; }
/** * Get an Add/Edit form for the object. * * @param string $target Post target for form submission */ public function getAddEditForm($target = '/admin/Cart') { $form = new Form('CartCategory_addedit', 'post', $target); $form->setConstants(array('section' => 'categories')); $form->addElement('hidden', 'section'); $form->setConstants(array('action' => 'addedit')); $form->addElement('hidden', 'action'); if (!is_null($this->getId())) { $form->setConstants(array('cartcategory_categories_id' => $this->getId())); $form->addElement('hidden', 'cartcategory_categories_id'); $defaultValues['cartcategory_name'] = $this->getName(); $defaultValues['cartcategory_description'] = $this->getDescription(); $defaultValues['cartcategory_image'] = $this->getImage(); $defaultValues['cartcategory_parent_id'] = $this->getParent_id(); $defaultValues['cartcategory_date_added'] = $this->getDate_added(); $defaultValues['cartcategory_last_modified'] = $this->getLast_modified(); $defaultValues['cartcategory_status'] = $this->getStatus(); $form->setDefaults($defaultValues); } $form->addElement('text', 'cartcategory_name', 'Name'); $description = $form->addElement('textarea', 'cartcategory_description', 'Description'); $description->setCols(80); $description->setRows(10); $newImage = $form->addElement('file', 'cartcategory_image_upload', 'Category Image'); $curImage = $form->addElement('dbimage', 'cartcategory_image', $this->getImage()); $form->addElement('select', 'cartcategory_parent_id', 'Parent Category', self::toArray()); $added = $form->addElement('text', 'cartcategory_date_added', 'Date Added'); $added->freeze(); $modified = $form->addElement('text', 'cartcategory_last_modified', 'Date Last Modified'); $modified->freeze(); $form->addElement('select', 'cartcategory_status', 'Status', Form::statusArray()); $form->addElement('submit', 'cartcategory_submit', 'Submit'); if (isset($_REQUEST['cartcategory_submit']) && $form->validate() && $form->isSubmitted()) { $this->setName($form->exportValue('cartcategory_name')); $this->setDescription($form->exportValue('cartcategory_description')); $this->setImage($form->exportValue('cartcategory_image')); $this->setParent_id($form->exportValue('cartcategory_parent_id')); $this->setDate_added($form->exportValue('cartcategory_date_added')); $this->setLast_modified($form->exportValue('cartcategory_last_modified')); $this->setStatus($form->exportValue('cartcategory_status')); if ($newImage->isUploadedFile()) { $im = new Image(); $id = $im->insert($newImage->getValue()); $this->setImage($im); $curImage->setSource($this->getImage()->getId()); } $this->save(); } return $form; }
public static function getForm() { $form = new Form('payment_form', 'payment_form', '/store/payment'); $types = self::getAllPayments(); $select_types = array(); foreach ($types as $type) { $select_types[$type->getClass()] = $type->getName(); } $defaults = array(); if (isset($_SESSION['cart_checkout']['payment'])) { $defaults['pay_type'] = $_SESSION['cart_checkout']['payment']->getClass(); } else { $_SESSION['cart_checkout']['payment'] = new Payment($type->getClass()); $defaults['pay_type'] = $_SESSION['cart_checkout']['payment']->getClass(); } $form->setDefaults($defaults); $form->addElement('select', 'pay_type', 'Payment Method', $select_types); $class = new $defaults['pay_type'](); if (!isset($_SESSION['cart_checkout']['payment'])) { $form = $class->getForm(&$form); } return $form; }