{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}

{% set modalSize = 'large' %}

{% block title %}编辑家长信息{% endblock %}
{% block body %}

<form id="user-edit-form" class="form-horizontal" method="post" action="{{ url('admin_parent_edit', {id:user.id}) }}">

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="truename">姓名</label>
    </div>
    <div class="col-md-7 controls">
      <input type="text" id="truename" name="truename" class="form-control" value="{{user.truename}}" >
    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="email">邮箱地址</label>
    </div>
    <div class="col-md-7 controls">
      <input type="text" id="email" data-url="{{path('admin_user_create_email_check',{id:user.id})}}" value="{{user.email}}" name="email" class="form-control" >
    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="gender">性别</label>
    </div>
    <div class="col-md-7 controls radios">
      <div id="gender">
        <input type="radio" id="gender_0" name="gender" value="male"
        {% if profile.gender == 'male' %} checked="checked" {% endif %}>
        <label for="gender_0">男</label>

        <input type="radio" id="gender_1" name="gender" value="female"
        {% if profile.gender == 'female' %} checked="checked" {% endif %}>
        <label for="gender_1">女</label>
      </div>

    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="familyRelation">家庭关系</label>
    </div>
    <div class="col-md-7">
      <select id="relation" name="relation" class="form-control" >
        {{ select_options(dict('family'), relation|default(''), '--家庭关系--') }}
      </select>
    </div>
  </div>

  <input type="hidden" id="numberInputNum" value="{{children|length-1}}" />
  <input type="hidden" id="dataSource" value="{{path('admin_student_match')}}">
  {% for child in children %}
    {% set index=loop.index-1 %}
    <div class="row form-group">
      <div class="col-md-2 control-label">
        {% if index==0 %}
          <label for="id_{{index}}">子女选择</label>
        {% else %}
          <label style="display:none" for="id_{{index}}">子女选择</label>
        {% endif %}
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="id_{{index}}" name="ids[]" class="select2-offscreen childId" data-url="{{path('admin_parent_create_childNumber_check')}}" value="{{child.truename}}({{child.number}})" data-id="{{ child.id|default('')}}" data-name="{{ child.truename|default('')}}({{child.number}})">
        
        <span class="glyphicon glyphicon-remove deleteNumberBtn"></span>
        {# form-control-feedback #}
      </div>
    </div>
  {% endfor %}

  <div class="row form-group">
    <div class="col-md-7 col-md-offset-2 control-label">
      <button id="addNumberBtn" type="button" class="btn btn-primary btn-block pull-left">+</button>
    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-2 control-label"> 
      <label for="idcard">身份证号</label>
    </div>
    <div class="col-md-7 controls">
      <input type="text" id="idcard" name="idcard" class="form-control" value="{{profile.idcard}}">
   </div>
  </div>

    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="mobile">手机号码</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="mobile" data-url="{{path('admin_user_create_mobile_check',{id:user.id})}}" name="mobile" class="form-control" value="{{user.mobile}}">
     </div>
    </div>

    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="title">头衔</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="title" name="title" class="form-control" value="{{profile.title}}">
     </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="signature">个人签名</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="signature" name="signature" class="form-control" value="{{profile.signature}}">
     </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="about">自我介绍</label>
      </div>
      <div class="col-md-7 controls">
        <textarea id="about" name="about">{{profile.about}}</textarea>
      </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="site">个人主页</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="site" name="site" class="form-control" value="{{profile.site}}">
     </div>
    </div>
    <p></p>
  <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="weibo">微博</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="weibo" name="weibo" class="form-control" value="{{profile.weibo}}">
     </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="qq">QQ</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="qq" name="qq" class="form-control" value="{{profile.qq}}">
     </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="weixin">微信</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="weixin" name="weixin" class="form-control" value="{{profile.weixin}}">
     </div>
    </div> 

    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">           

{% if fields %}
          <hr>
          {% for field in fields %}
          {% if field.type=="text" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <textarea id="{{field.fieldName}}" name="{{field.fieldName}}" class="{{field.type}} form-control" >{{ profile[field.fieldName]|default('') }}</textarea>
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% elseif field.type=="int" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <input type="text" id="{{field.fieldName}}" placeholder="最大值为9位整数" name="{{field.fieldName}}" class="{{field.type}} form-control"  value="{{ profile[field.fieldName]|default('') }}">
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% elseif field.type=="float" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <input type="text" id="{{field.fieldName}}" placeholder="保留到2位小数" name="{{field.fieldName}}" class="{{field.type}} form-control" value="{{ profile[field.fieldName]|default('') }}">
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% elseif field.type=="date" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <input type="text" id="{{field.fieldName}}" name="{{field.fieldName}}" class="{{field.type}} form-control"   value="{% if profile[field.fieldName] %}{{profile[field.fieldName]}}{% endif %}">
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% elseif field.type=="varchar" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <input type="text" id="{{field.fieldName}}" name="{{field.fieldName}}" class="form-control"  value="{{ profile[field.fieldName]|default('') }}">
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% endif %}
          {% endfor %}
          {% endif %}

</form>
{% endblock %}

{% block footer %}
  <button id="edit-user-btn" data-submiting-text="正在提交" type="submit" class="btn btn-primary pull-right" data-toggle="form-submit" data-target="#user-edit-form">保存</button>
  <button type="button" class="btn btn-link pull-right" data-dismiss="modal">取消</button>
  <script>app.load('parent/edit-modal')</script>
{% endblock %}