当前位置: 首页>>代码示例>>PHP>>正文


PHP AdminForm::prepare方法代码示例

本文整理汇总了PHP中AdminForm::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminForm::prepare方法的具体用法?PHP AdminForm::prepare怎么用?PHP AdminForm::prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AdminForm的用法示例。


在下文中一共展示了AdminForm::prepare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Alias

    $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();
    }
    $category->alias = $alias;
} elseif (isset($path[2]) && $path[2] == 'edit') {
    $category = new Category($db, $path[3]);
    $category->alias = new Alias($db, $category->val('category_alias_id'));
    $page_title = t('Editing Category');
} elseif (isset($path[2]) && $path[2] == 'delete') {
    $category = new Category($db);
    $category->deleteById($path[3]);
    redirect('/admin/categories');
} else {
    $category = new Category($db);
    $page_title = t('New Category');
}
$form->prepare($db, $category);
开发者ID:lotcz,项目名称:zshop,代码行数:30,代码来源:category.c.php

示例2: AdminForm

$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);
    $page_title = t('New Customer');
}
$form->prepare($db, $customer);
开发者ID:lotcz,项目名称:zshop,代码行数:30,代码来源:customer.c.php


注:本文中的AdminForm::prepare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。