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

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

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

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

        <h1 class="pull-right">
            <a href="<?=$this->url('position');?>" class="btn btn-default btn-sm"><i class="fa fa-arrow-left"></i> <?=$this->translate('返回仓位列表')?></a>
            <button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-check"></i> <?=$this->translate('保存仓位')?></button>
            <?=(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"><?=((isset($position) && $position->getPositionId()) ? $this->translate('编辑仓位') : $this->translate('添加仓位'))?></h3>
                    </div>

                    <div class="box-body">
                        <?=$this->formElementErrors($form->get('dberp_csrf'), ['class'=>'error-message']); ?>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?=$this->translate('仓位号')?><span class="must_add_value">*</span></label>
                            <div class="col-sm-6">
                                <?= $this->formElement($form->get('positionSn')); ?>
                                <?= $this->formElementErrors($form->get('positionSn'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label"><?=$this->translate('选择仓库')?><span class="must_add_value">*</span></label>
                            <div class="col-sm-3">
                                <?= $this->formElement($form->get('warehouseId')); ?>
                                <?= $this->formElementErrors($form->get('warehouseId'), ['class'=>'error-message']); ?>
                            </div>
                        </div>

                    </div>

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

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

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

</div>
<script>
    $(document).ready(function() {
        $("#<?=$form->getName()?>").validate({
            rules: {
                positionSn: {
                    required: true
                },
                warehouseId: {
                    required: true
                }
            },
            messages: {
                positionSn: {
                    required: "<?=$this->translate('仓位编号不能为空！')?>"
                },
                warehouseId: {
                    required: "<?=$this->translate('请选择仓库！')?>"
                }
            }
        });
    });
</script>
