<div class="content-wrapper">
    <?php
    $form = $this->form;
    $form->prepare();

    $form->get('supplierCategoryCode')->setAttributes([
        'placeholder' => $this->translate('供应商分类编码')
    ]);

    $form->get('supplierCategoryName')->setAttributes([
        'placeholder' => $this->translate('供应商分类名称')
    ]);

    $form->get('supplierCategorySort')->setAttributes([
        'placeholder' => $this->translate('供应商分类排序')
    ]);

    ?>
    <?php echo $this->form()->openTag($form); ?>
    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right">
            <a href="<?php echo $this->url('supplier-category');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?php echo $this->translate('返回供应商分类列表'); ?></a>
            <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-check"></i> <?php echo $this->translate('保存供应商分类'); ?></button>
            <?php echo (isset($supplierCategory) ? $this->HelpUrl('supplierCategoryEdit') : $this->HelpUrl('supplierCategoryAdd')); ?>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?php echo ((isset($supplierCategory) && $supplierCategory->getSupplierCategoryId()) ? $this->translate('编辑供应商分类') : $this->translate('添加供应商分类')); ?></h3>
                    </div>

                    <div class="box-body">
                        <?php echo $this->formElementErrors($form->get('dberp_csrf'), ['class'=>'error-message']); ?>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?php echo $this->translate('供应商分类编码'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('supplierCategoryCode')); ?>
                                <?php echo $this->formElementErrors($form->get('supplierCategoryCode'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?php echo $this->translate('供应商分类名称'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-6">
                                <?php echo $this->formElement($form->get('supplierCategoryName')); ?>
                                <?php echo $this->formElementErrors($form->get('supplierCategoryName'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?php echo $this->translate('排序'); ?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?php echo $this->formElement($form->get('supplierCategorySort')); ?>
                                <?php echo $this->formElementErrors($form->get('supplierCategorySort'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                    </div>

                    <div>
                        <div class="box-footer">
                            <?php echo $this->formElement($form->get('dberp_csrf')); ?>
                            <button type="submit" class="btn btn-primary col-md-offset-2"><i class="fa fa-check"></i> <?php echo $this->translate('保存供应商分类'); ?></button>
                        </div>
                    </div>

                </div>
            </div>
        </div>

    </section>
    <?php echo $this->form()->closeTag(); ?>

</div>
<script type="text/javascript">
    $(document).ready(function() {
        $("#<?php echo $form->getName(); ?>").validate({
            rules: {
                supplierCategoryCode: {
                    required: true
                },
                supplierCategoryName: {
                    required: true
                },
                supplierCategorySort: {
                    required: true,
                    number: true,
                    min: 1
                }
            },
            messages: {
                supplierCategoryCode: {
                    required: "<?php echo $this->translate('供应商分类编码不能为空！'); ?>"
                },
                supplierCategoryName: {
                    required: "<?php echo $this->translate('供应商分类名称不能为空！'); ?>"
                },
                supplierCategorySort: {
                    required: "<?php echo $this->translate('排序不能为空！'); ?>",
                    number: "<?php echo $this->translate('排序必须为数字！'); ?>",
                    min: "<?php echo $this->translate('排序最小为1！'); ?>"
                }
            }
        });
    });
</script>