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

    $form->get('positionSn')->setAttributes([
        'placeholder' => $this->translate('仓位编号')
    ]);

    $form->get('warehouseId')->setEmptyOption('请选择仓库');

    ?>
    <?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('position');?>" 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($position) ? $this->HelpUrl('positionEdit') : $this->HelpUrl('positionAdd')); ?>
        </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($position) && $position->getPositionId()) ? $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-6">
                                <?php echo $this->formElement($form->get('positionSn')); ?>
                                <?php echo $this->formElementErrors($form->get('positionSn'), ['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('warehouseId')); ?>
                                <?php echo $this->formElementErrors($form->get('warehouseId'), ['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: {
                positionSn: {
                    required: true
                },
                warehouseId: {
                    required: true
                }
            },
            messages: {
                positionSn: {
                    required: "<?php echo $this->translate('仓位编号不能为空！'); ?>"
                },
                warehouseId: {
                    required: "<?php echo $this->translate('请选择仓库！'); ?>"
                }
            }
        });
    });
</script>
