本文整理汇总了PHP中AdminForm::add方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminForm::add方法的具体用法?PHP AdminForm::add怎么用?PHP AdminForm::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminForm
的用法示例。
在下文中一共展示了AdminForm::add方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AdminForm
<?php
require_once $home_dir . 'models/language.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('language');
$page = 'admin/form';
$form->add([['name' => 'language_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1], ['type' => 'maxlen', 'param' => 100]]], ['name' => 'language_code', 'label' => 'Code', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1], ['type' => 'maxlen', 'param' => 10]]], ['name' => 'language_decimal_separator', 'label' => 'Decimal Separator', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1], ['type' => 'maxlen', 'param' => 10]]], ['name' => 'language_thousands_separator', 'label' => 'Thousand Separator', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1], ['type' => 'maxlen', 'param' => 10]]], ['name' => 'language_default_currency_id', 'label' => 'Default Currency', 'type' => 'select', 'select_table' => 'currencies', 'select_id_field' => 'currency_id', 'select_label_field' => 'currency_name']]);
Language::process($db, $form);
示例2: AdminForm
<?php
require_once $home_dir . 'models/currency.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('currency');
$page = 'admin/form';
$form->add([['name' => 'currency_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]], ['name' => 'currency_format', 'label' => 'Format', 'type' => 'text', 'hint' => 'This specifies how prices will be displayed in this currency. Put token %s where you want amount to be.'], ['name' => 'currency_value', 'label' => 'Value', 'type' => 'text', 'hint' => 'Put value 1 for default currency.', 'validations' => [['type' => 'price'], ['type' => 'min', 'param' => 0]]], ['name' => 'currency_decimals', 'label' => 'Displayed decimals', 'type' => 'text', 'hint' => 'This specifies how many decimal places will be displayed for prices in this currency.', 'validations' => [['type' => 'integer']]]]);
Currency::process($db, $form);
示例3: AdminForm
<?php
require_once $home_dir . 'models/product.m.php';
require_once $home_dir . 'models/category.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('product');
$page = 'admin/form';
$form->add([['name' => 'product_ext_id', 'label' => 'ABX ID', 'type' => 'static'], ['name' => 'product_category_id', 'label' => 'Category', 'type' => 'select', 'select_table' => 'categories', 'select_data' => Category::getTreeForSelect($db), 'select_id_field' => 'category_id', 'select_label_field' => 'category_name'], ['name' => 'product_name', 'label' => 'Name', 'type' => 'text'], ['name' => 'product_price', 'label' => 'Price', 'type' => 'text', 'validations' => [['type' => 'price']]], ['name' => 'product_description', 'label' => 'Description', 'type' => 'static'], ['name' => 'product_image', 'label' => 'Image', 'type' => 'image']]);
Product::process($db, $form);
示例4: AdminForm
<?php
require_once $home_dir . 'models/payment_type.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('payment_type');
$page = 'admin/form';
$form->add([['name' => 'payment_type_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]], ['name' => 'payment_type_price', 'label' => 'Price', 'type' => 'text', 'validations' => [['type' => 'price']]], ['name' => 'payment_type_min_order_cost', 'label' => 'Min. order cost', 'type' => 'text', 'validations' => [['type' => 'price']]], ['name' => 'payment_type_is_default', 'label' => 'Is Default', 'type' => 'bool']]);
PaymentType::process($db, $form);
示例5: AdminForm
<?php
require_once $home_dir . 'models/category.m.php';
require_once $home_dir . 'models/alias.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('category');
$page = 'admin/form';
$form->add([['name' => 'category_name', 'label' => 'Name', 'type' => 'text'], ['name' => 'alias_url', 'label' => 'Alias', 'type' => 'text'], ['name' => 'category_parent_id', 'label' => 'Parent Category', 'type' => 'select', 'select_table' => 'categories', 'select_id_field' => 'category_id', 'select_label_field' => 'category_name']]);
if (isset($_POST['category_id'])) {
$category = new Category($db, $_POST['category_id']);
$category->setData($form->processInput($_POST));
$category->data['category_parent_id'] = parseInt($category->val('category_parent_id'));
$alias_url = $category->val('alias_url');
unset($category->data['alias_url']);
$category->save();
$alias = new Alias($db, $category->ival('category_alias_id'));
// save alias if new or changed
if ($alias->val('alias_url') != $alias_url || !$alias->is_loaded) {
$alias->data['alias_path'] = $category->getAliasPath();
if (isset($alias_url) && strlen(trim($alias_url)) > 0) {
$alias->setUrl($alias_url);
} else {
$alias->setUrl($category->getAliasUrl());
}
$alias->save();
}
// update category alias if changed
if ($alias->ival('alias_id') != $category->ival('category_alias_id')) {
$category->data['category_alias_id'] = $alias->ival('alias_id');
$category->save();
}
示例6: AdminForm
<?php
require_once $home_dir . 'models/customer.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('customer');
$page = 'admin/form';
$form->add([['name' => 'customer_created', 'label' => 'Date', 'type' => 'static'], ['name' => 'customer_last_access', 'label' => 'Last visited', 'type' => 'static'], ['name' => 'customer_deleted', 'label' => 'Deleted', 'type' => 'bool'], ['name' => 'customer_anonymous', 'label' => 'Anonymous', 'type' => 'bool'], ['label' => 'Login', 'type' => 'begin_group'], ['name' => 'customer_email', 'label' => 'E-mail', 'type' => 'text', 'validations' => [['type' => 'email']]], ['name' => 'customer_password', 'label' => 'Password', 'type' => 'password', 'validations' => [['type' => 'password']]], ['name' => 'customer_password_confirm', 'label' => 'Confirm Password', 'type' => 'password', 'validations' => [['type' => 'confirm', 'param' => 'customer_password']]], ['type' => 'end_group'], ['label' => 'Address', 'type' => 'begin_group'], ['name' => 'customer_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'maxlen', 'param' => 50]]], ['name' => 'customer_address_city', 'label' => 'City', 'type' => 'text', 'validations' => [['type' => 'maxlen', 'param' => 50]]], ['name' => 'customer_address_street', 'label' => 'Street with house n.', 'type' => 'text', 'validations' => [['type' => 'maxlen', 'param' => 50]]], ['name' => 'customer_address_zip', 'label' => 'ZIP', 'type' => 'text', 'validations' => [['type' => 'integer', 'param' => true]]], ['type' => 'end_group'], ['label' => 'Shipping Address', 'type' => 'begin_group'], ['name' => 'customer_ship_name', 'label' => 'Name (shipping)', 'type' => 'text', 'validations' => [['type' => 'maxlen', 'param' => 50]]], ['name' => 'customer_ship_city', 'label' => 'City (shipping)', 'type' => 'text', 'validations' => [['type' => 'maxlen', 'param' => 50]]], ['name' => 'customer_ship_street', 'label' => 'Street (shipping)', 'type' => 'text', 'validations' => [['type' => 'maxlen', 'param' => 50]]], ['name' => 'customer_ship_zip', 'label' => 'ZIP (shipping)', 'type' => 'text', 'validations' => [['type' => 'integer', 'param' => true]]], ['type' => 'end_group'], ['name' => 'customer_failed_attempts', 'label' => 'Failed attempts', 'type' => 'text', 'validations' => [['type' => 'integer']]], ['name' => 'customer_delivery_type_id', 'label' => 'Delivery Type', 'type' => 'select', 'select_table' => 'delivery_types', 'select_id_field' => 'delivery_type_id', 'select_label_field' => 'delivery_type_name'], ['name' => 'customer_payment_type_id', 'label' => 'Payment Type', 'type' => 'select', 'select_table' => 'payment_types', 'select_id_field' => 'payment_type_id', 'select_label_field' => 'payment_type_name']]);
if (isset($_POST['customer_id'])) {
if ($_POST['customer_id'] > 0) {
$customer = new Customer($db, $_POST['customer_id']);
} else {
$customer = new Customer($db);
}
$customer->setData($form->processInput($_POST));
unset($customer->data['customer_password']);
unset($customer->data['customer_password_confirm']);
if (isset($_POST['customer_password']) && strlen($_POST['customer_password']) > 0) {
$customer->data['customer_password_hash'] = CustomerAuthentication::hashPassword($_POST['customer_password']);
}
if ($customer->save()) {
redirect(_g('r', '/admin/customers'));
}
} elseif (isset($path[2]) && $path[2] == 'edit') {
$customer = new Customer($db, $path[3]);
$page_title = t('Editing Customer');
} elseif (isset($path[2]) && $path[2] == 'delete') {
if (Customer::del($db, $path[3])) {
redirect(_g('r', '/admin/customers'));
}
} else {
$customer = new Customer($db);
示例7: AdminForm
<?php
require_once $home_dir . 'models/delivery_type.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('delivery_type');
$page = 'admin/form';
$form->add([['name' => 'delivery_type_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]], ['name' => 'delivery_type_price', 'label' => 'Price', 'type' => 'text', 'validations' => [['type' => 'price']]], ['name' => 'delivery_type_min_order_cost', 'label' => 'Min. order cost', 'type' => 'text', 'validations' => [['type' => 'price']]]]);
DeliveryType::process($db, $form);
示例8: AdminForm
<?php
require_once $home_dir . 'models/order.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('order');
$page = 'admin/form';
$form->add([['name' => 'order_id', 'label' => 'Order ID', 'type' => 'hidden'], ['name' => 'order_created', 'label' => 'Date', 'type' => 'static', 'disabled' => 'disabled'], ['name' => 'order_order_state_id', 'label' => 'Status', 'type' => 'select', 'select_table' => 'order_states', 'select_id_field' => 'order_state_id', 'select_label_field' => 'order_state_name'], ['name' => 'order_customer_id', 'label' => 'Customer', 'type' => 'foreign_key_link', 'link_table' => 'customers', 'link_template' => 'admin/customer/edit/%d', 'link_id_field' => 'customer_id', 'link_label_field' => 'customer_name'], ['name' => 'order_payment_code', 'label' => 'Payment Code', 'type' => 'text', 'disabled' => 'disabled'], ['name' => 'order_ship_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]], ['name' => 'order_ship_city', 'label' => 'City', 'type' => 'text'], ['name' => 'order_ship_street', 'label' => 'Street', 'type' => 'text'], ['name' => 'order_ship_zip', 'label' => 'ZIP', 'type' => 'text']]);
Order::process($db, $form);
示例9: AdminForm
<?php
require_once $home_dir . 'models/alias.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('alias');
$page = 'admin/form';
$form->add([['name' => 'alias_url', 'label' => 'URL', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]], ['name' => 'alias_path', 'label' => 'Path', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]]]);
Alias::process($db, $form);
示例10: AdminForm
<?php
require_once $home_dir . 'models/ip_failed.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('ip_failed_attempt');
$page = 'admin/form';
$form->add([['name' => 'ip_failed_attempt_ip', 'label' => 'IP', 'type' => 'text', 'validations' => [['type' => 'ip']]], ['name' => 'ip_failed_attempt_count', 'label' => 'Failed Attempts', 'type' => 'text', 'validations' => [['type' => 'integer']]], ['name' => 'ip_failed_attempt_first', 'label' => 'First', 'type' => 'date', 'hint' => 'Date of the first failed attempt.', 'validations' => [['type' => 'date']]], ['name' => 'ip_failed_attempt_last', 'label' => 'Last', 'type' => 'date', 'hint' => 'Date of the last failed attempt.', 'validations' => [['type' => 'date']]]]);
IpFailedAttempt::process($db, $form);
示例11: AdminForm
<?php
require_once $home_dir . 'models/language.m.php';
require_once $home_dir . 'models/translation.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('translation');
$page = 'admin/form';
$form->add([['name' => 'translation_language_id', 'label' => 'Language', 'type' => 'select', 'select_table' => 'languages', 'select_data' => Language::all($db), 'select_id_field' => 'language_id', 'select_label_field' => 'language_name'], ['name' => 'translation_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1], ['type' => 'maxlen', 'param' => 255]]], ['name' => 'translation_translation', 'label' => 'Translation', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]]]);
Translation::process($db, $form);
示例12: AdminForm
<?php
require_once $home_dir . 'models/role.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('role');
$page = 'admin/form';
$form->add([['name' => 'role_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]], ['name' => 'role_description', 'label' => 'Description', 'type' => 'text']]);
Role::process($db, $form);