src/Crud/templates/crud/formulario.html.twig line 1

Open in your IDE?
  1. {% block formulario_jquery %}
  2.     <script type="text/javascript">
  3.         function mostrarTextoGeometria(geometria)
  4.         {
  5.             cadenaRetorno = '';
  6.             if (geometria.length)
  7.             {
  8.                 cadena = geometria.replace('POINT(','');
  9.                 cadena = cadena.replace(')','');
  10.                 punto = cadena.split(' ');
  11.                 cadenaRetorno = 'Lat:'+ parseFloat(punto[1]).toFixed(2) + ' Lon:'+ parseFloat(punto[0]).toFixed(2);
  12.             }
  13.             return cadenaRetorno;
  14.         }
  15.         {% block formulario_customs_functions %}
  16.         {% endblock formulario_customs_functions %}
  17.         $(function(){
  18.         
  19.             $('.just_numbers').keypress(function(e){
  20.                 if (e.which<48 || e.which>57 )
  21.                     e.preventDefault();
  22.             });
  23.             $('.just_floats').keypress(function(e){
  24.                 if (e.which === 46)  //el punto
  25.                     {
  26.                         //buscar si ya hay un punto
  27.                         var val = $(this).val();
  28.                         if (val.indexOf('.')>=0)
  29.                         {
  30.                             e.preventDefault();
  31.                         }
  32.                     }
  33.                     else
  34.                         if (e.which<48 || e.which>57 )
  35.                             e.preventDefault();
  36.             });
  37.         
  38.             $("#crud_form_{{ routeClassName }}").find(".form-control").each(function () {
  39.                 var idK=$(this).attr('id');
  40.                 if (idK)
  41.                 {
  42.                     var idW = idK.replace('form','');
  43.                     idW = 'form_{{ routeClassName}}'+ idW;
  44.                     $(this).attr('id',idW);
  45.                     $(this).removeClass('form-control');
  46.                 }
  47.             });
  48.             
  49.             {% for key,widget in form %}
  50.                 {% if key != '_token' %}
  51.                     {% if widget.vars.attr.readonly is defined %}
  52.                         $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').addClass('hide');
  53.                     {% endif %}
  54.                     {% if widget.vars.attr.dependiente_parent is defined %}
  55.                         $('#form_{{ widget.vars.attr.dependiente_parent }}').change(function(){
  56.                             var selected = $(this).val();
  57.                             if (selected=="") selected="-1";
  58. //                            var baseSite = document.getElementById('baseSite').value;
  59.                             var url = '{{ path('crudDependiente', {'rol': 'all', 'className': widget.vars.attr.dependiente_class, 'fieldName': widget.vars.attr.dependiente_field, 'value': '__VALUE__'}) }}';
  60.                             url = url.replace('__VALUE__',selected);
  61. //                            var url = baseSite+"dependientes/{{ widget.vars.attr.dependiente_class }}/{{ widget.vars.attr.dependiente_field }}/"+selected;
  62.                             $('#{{ key }}').mask('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
  63.                             $('#form_{{ routeClassName }}_{{ key }}').load(url, function(){
  64.                                 $('#{{ key }}').unmask();
  65.                             });
  66.                         });
  67.                     {% endif %}
  68.                     {% if widget.vars.attr.class is defined %}
  69.                         {% if isSubString(widget.vars.attr.class,'spinbox-input') %}
  70.                             {% set min = "" %}
  71.                             {% if widget.vars.attr.min is defined %}
  72.                                 {% set min = "min: "~widget.vars.attr.min~", " %}
  73.                             {% endif %}
  74.                             {% set max = "" %}
  75.                             {% if widget.vars.attr.max is defined %}
  76.                                 {% set max = "max: "~widget.vars.attr.max~", " %}
  77.                             {% endif %}
  78.                             $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').attr('type','text');
  79.                             $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').ace_spinner({ {{ min }}{{ max }} step: 1, on_sides: true, icon_up: 'fas fa-plus', icon_down: 'fas fa-minus ', btn_up_class: 'btn-grey', btn_down_class: 'btn-grey', full_width: true});
  80.                         {% else %}
  81.                             {% if isSubString(widget.vars.attr.class,'campo_fecha') %}
  82.                                 $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').wrap('<div class="input-group" id="campo_fecha_{{ routeClassName }}_{{ key}}" />');
  83.                                 $('#campo_fecha_{{ routeClassName }}_{{ key}}').append('<span class="input-group-addon"><i class="fas fa-calendar bigger-110"></i></span>');
  84.                                 $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').attr('type','text');
  85.                                 $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').datepicker({
  86.                                         autoclose: true,
  87.                                         todayHighlight: true,
  88.                                         {% if widget.vars.attr.startDate is defined %}
  89.                                             startDate: '{{ widget.vars.attr.startDate }}',
  90.                                         {% endif %}
  91.                                         {% if widget.vars.attr.endDate is defined %}
  92.                                             endDate: '{{ widget.vars.attr.endDate }}',
  93.                                         {% endif %}
  94.                                         language: '{{ app.request.locale }}'
  95.                                 })
  96.                                 .next().on(ace.click_event, function(){
  97.                                         $(this).prev().focus();
  98.                                 });
  99.                             {% else %}
  100.                                 {% if isSubString(widget.vars.attr.class,'campo_hora_fecha') %}
  101.                                     $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').wrap('<div class="input-group" id="campo_fecha_{{ routeClassName }}_{{ key}}" />');
  102.                                     $('#campo_fecha_{{ routeClassName }}_{{ key}}').append('<span class="input-group-addon"><i class="fas fa-calendar bigger-110"></i></span>');
  103.                                     $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').datetimepicker()
  104.                                     .next().on(ace.click_event, function(){
  105.                                                 $(this).prev().focus();
  106.                                     });
  107.                                 {% else %}
  108.                                     {% if isSubString(widget.vars.attr.class,'geometria_punto') %}
  109.                                         $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').change(function(){
  110.                                             geometria = $(this).val();
  111.                                             valor = mostrarTextoGeometria(geometria);
  112.                                             $('#textoGeometriaPunto').html(valor);
  113.                                         });
  114.                                         $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').trigger('change');
  115.                                     {% else %}
  116.                                         {% if isSubString(widget.vars.attr.class,'geometria_poligono') %}
  117.                                             $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').change(function(){
  118.                                                 $('#textoGeometriaPoligono').html('Pol�gono definido');
  119.                                             });
  120.                                             if($('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').val())
  121.                                                 $('#textoGeometriaPoligono').html('Pol�gono definido');
  122.                                         {% else %}
  123.                                             {% if isSubString(widget.vars.attr.class,'dolar') %}
  124.                                                 $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').wrap('<div class="input-group"/>');
  125.                                                 $('#crud_form_{{ routeClassName }}').find('#form_{{ routeClassName }}_{{ key}}').parent().prepend("<span class='input-group-addon'>$</span>");
  126.                                             {% endif %}
  127.                                         {% endif %}
  128.                                     {% endif %}
  129.                                 {% endif %}
  130.                             {% endif %}
  131.                         {% endif %}
  132.                     {% endif %}
  133.                 {% endif %}
  134.             {% endfor %}
  135.             
  136.         
  137.             {% block formulario_customs_jquery %}
  138.             {% endblock formulario_customs_jquery %}
  139.         });
  140.     </script>
  141. {% endblock %}
  142. {% block formulario_content %}
  143.     {% block secondary_heading %}
  144.     {% endblock %}
  145.     {% if not btnSave is defined %}
  146.         {% set btnSave='btn_do_and_list' %}
  147.     {% endif %}
  148.     {% block pre_form %}
  149.     {% endblock %}
  150.     {% block form_action %}
  151.     {% endblock %}
  152.     {% block form %}
  153.         {% set rowopen=false %}
  154.         {% set maxcol=formColumns %}
  155.         {% set col=0 %}
  156.         {% block form_pre_rows %}
  157.         {% endblock form_pre_rows %}
  158.         {% for param, value in paramsRequest %}
  159.             {% if value is iterable %}
  160.                 {% for val in value %}
  161.                     <input name="{{ param }}" type='hidden' value='{{ val }}'>
  162.                 {% endfor %}
  163.             {% else %}
  164.                 <input id="{{ param }}" name="{{ param }}" type='hidden' value='{{ value }}'>
  165.             {% endif %}
  166.         {% endfor %}
  167.         <input id='form_accion_{{ routeClassName }}' type='hidden' value='{{ accion }}'>
  168.         {#% for key,widget in form %}
  169.                 {% for k,el in widget.vars if k != 'is_selected'%}
  170.                     {% if k=='attr' or k=='form' or k=='block_prefixes' or k=='errors' or k=='label_attr' or k=='preferred_choices' or k=='choices' %}
  171.                         {% for k1,el1 in widget.vars.attr %}
  172.                             {{ k }}=>{{ k1 }}=>{{ el1 }}<br>
  173.                         {% endfor %}
  174.                     {% else %}
  175.                         {{ k }}=>{{ el }}<br>
  176.                     {% endif %}
  177.                 {% endfor %}
  178.         {% endfor %#}
  179.         {% for key,widget in form %}
  180.             {% if notShow[key] is not defined %}
  181.                 {% if widget.vars.attr['containerclass'] is defined %}
  182.                     {% if  isSubString(widget.vars.attr['containerclass'],'full-row') %}
  183.                         {% if rowopen %}
  184.                             </div>
  185.                             <div class="row">
  186.                         {% endif %}
  187.                         {% set col=maxcol-1 %}
  188.                     {% endif %}
  189.                 {% endif %}
  190.                 {% if not rowopen %}
  191.                     {% block rowopen %}
  192.                         <div class="row">
  193.                     {% endblock rowopen %}
  194.                     {% set rowopen=true %}
  195.                 {% endif %}
  196.                 {#% for k,el in widget.vars if k != 'is_selected'%}
  197.                     {% if k=='attr' or k=='form' or k=='block_prefixes' or k=='errors' or k=='label_attr' or k=='preferred_choices' or k=='choices' %}
  198.                         {% for k1,el1 in widget.vars.attr %}
  199.                             {{ k }}=>{{ k1 }}=>{{ el1 }}<br>
  200.                         {% endfor %}
  201.                     {% else %}
  202.                         {{ k }}=>{{ el }}<br>
  203.                     {% endif %}
  204.                 {% endfor %#}
  205.                 {% block draw_widget %}
  206.                 {% set col_class='col-xs-12' %}
  207.                 {% if widget.vars.attr['containerclass'] is not defined or not isSubString(widget.vars.attr['containerclass'],'full-row') %}
  208.                     {% if maxcol>1 %}
  209.                         {% set col_class=col_class~' col-sm-6' %}
  210.                     {% endif %}
  211.                     {% set col_class=col_class~' col-md-'~12/maxcol %}
  212.                 {% endif %}
  213.                 {% if widget.vars.attr['containerclass'] is defined %}
  214.                     {% set col_class=col_class~' '~widget.vars.attr['containerclass'] %}
  215.                 {% endif %}
  216.                 <div id="{{key}}" class="{{ col_class }}">
  217.                     <table class="table table-striped table-bordered table-hover">
  218.                         <tr>
  219.                             <th style="width: {{ widthLabel }}; vertical-align: middle">
  220.                                 {% set required = '' %}
  221.                                 {% if widget.vars.required %}
  222.                                 {%   set required = 'required' %}
  223.                                 {% endif %}
  224.                                 <label class="crud_label {{required}}" id="label_form_{{ routeClassName }}_{{ key }}" {% if widget.vars.attr.tip is defined %}data-rel="tooltip" data-trigger="hover" data-placement="top" data-content="More details." title="{{ widget.vars.attr.tip }}" style="cursor: help"{% endif %}>
  225.                                     {{widget.vars.label}}
  226.                                 </label>
  227.                                 {% if widget.vars.attr.relation is defined %}
  228.                                     <label onclick="javascript:creaNuevoRelacion('{{ routeClassName }}','form_{{ routeClassName }}_{{ key }}'); return false;" class="relacion" data-rel="tooltip" data-trigger="hover" data-placement="top" data-content="More details." title="Si no encuentra en la lista la información que necesita, pinche aquí para adicionarla" style="cursor: pointer" itemid="form_{{ routeClassName }}_{{ key }}">
  229.                                         <i class="icon fas fa-plus-square green" itemid="{{ widget.vars.id }}"></i>&nbsp;
  230.                                     </label>
  231.                                 {% endif %}
  232.                             </th>
  233.                             <td style="vertical-align: middle" class="crud_td">
  234.                                 {% if widget.vars.type is defined and widget.vars.type=='file' and entity.getFieldValue(widget.vars.name)%}
  235.                                     <div id="hidefile_{{ routeClassName }}_{{ widget.vars.id }}">
  236.                                         {% if widget.vars.attr.accept is defined and isSubString(widget.vars.attr.accept,'image') %}
  237.                                             <img src="{{ absolute_url(entity.getFieldValue(widget.vars.name).getUrl()) }}" width='80px'>
  238.                                         {% else %}
  239.                                             <a target="_blank" href="{{ absolute_url(entity.getFieldValue(widget.vars.name).getUrl()) }}">{{entity.getFieldValue(widget.vars.name).getFileName() }}</a>
  240.                                         {% endif %}
  241.                                         {% if widget.vars.attr.readonly is not defined %}                                        
  242.                                             <span class="action-buttons">
  243.                                                 <a class="hide_item_{{ routeClassName }}" id="hide_form_{{ routeClassName }}_{{ key }}" item_id="form_{{ key }}" href=""><i class="fas fa-trash red bigger-130" title="{% trans from 'crud' %}botones.eliminar_adjunto{% endtrans %}"></i></a>
  244.                                             </span>
  245.                                         {% endif %}
  246.                                         <input type="hidden" id="oldfile_form_{{ routeClassName }}_{{ key }}" value="clear" name="oldfile[{{ widget.vars.name }}]">
  247.                                     </div>
  248.                                     {% if widget.vars.attr.readonly is not defined %}                                        
  249.                                         <div id="file_{{ routeClassName }}_form_{{ key }}" class="hide {% if widget.vars.required is defined and widget.vars.required %}required{% endif %}">
  250.                                             {{ form_widget(widget) }}
  251.                                         </div>
  252.                                     {% endif %}
  253.                                 {% else %}
  254.                                     {% if widget.vars.attr.class is defined and isSubString(widget.vars.attr.class,'geometria_punto') %}
  255.                                         <a class="botonmapaPunto noti btn-minier" title="Definir Ubicación en Mapa" itemid="form_{{ routeClassName }}_{{ key }}" geom="punto" href="#">
  256.                                             <i class="ace-icon fa fa-globe bigger-220 blue"></i>
  257.                                         </a>
  258.                                         <span id="textoGeometriaPunto"></span>
  259.                                         {{ form_widget(widget) }}
  260.                                     {% else %}
  261.                                         {% if widget.vars.attr.class is defined and isSubString(widget.vars.attr.class,'geometria_poligono') %}
  262.                                             <a class="botonmapa noti btn-minier" title="Definir Ubicación en Mapa" itemid="form_{{ routeClassName }}_{{ key }}" geom="poligono" href="#">
  263.                                                 <i class="fas fa-globe bigger-220 blue"></i>
  264.                                             </a>
  265.                                             <span id="textoGeometriaPoligono"></span>
  266.                                             {{ form_widget(widget) }}
  267.                                         {% else %}
  268.                                             {% if widget.vars.attr.class is defined and isSubString(widget.vars.attr.class,'ace-switch') %}
  269.                                                 <div style="text-align: center">
  270.                                                     <label class="block" style='margin-bottom: 0! important'>
  271.                                                         {{ form_widget(widget) }}
  272.                                                         <span class="lbl" data-lbl="{{ 'choice_value.yes' | trans({}, 'crud') | upper}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ 'choice_value.no'  | trans({}, 'crud') | upper}}"></span>
  273.                                                     </label>
  274.                                                 </div>
  275.                                             {% else %}
  276.                                                 {% if widget.vars.attr.readonly is defined %}
  277.                                                     <span id="span_{{ routeClassName }}_{{ key }}">{{ entity.getFieldValue(widget.vars.name, true) }}</span>
  278.                                                 {% else %}
  279.                                                     {{ form_widget(widget) }}
  280.                                                 {% endif %}
  281.                                             {% endif %}
  282.                                         {% endif %}
  283.                                     {% endif %}
  284.                                 {% endif %}
  285.                             </td>
  286.                         </tr>
  287.                     </table>
  288.                 </div>
  289.                                 {% endblock draw_widget %}
  290.                 {% set col = col + 1 %}
  291.                 {% if col == maxcol %}
  292.                     {% block rowclose %}
  293.                         </div>
  294.                     {% endblock rowclose %}
  295.                     {% set rowopen=false %}
  296.                     {% set col=0 %}
  297.                 {% endif %}
  298.             {%endif%}
  299.         {% endfor %}
  300.         {% if rowopen %}
  301.             </div>
  302.         {% endif %}
  303.         {% block form_post_rows %}
  304.         {% endblock form_post_rows %}
  305.         <div class="row hide">
  306.             <table>{{ form_rest(form) }}</table>
  307.         </div>
  308.     {% endblock %}
  309.     {% block post_form %}
  310.         <input type="hidden" id="relaciontarget-{{ routeClassName }}">
  311.         <input type="hidden" id="relacionnombre-{{ routeClassName }}">
  312.         <div id="dialog-mapa-{{ routeClassName }}" title="Definir Ubicación en Mapa"></div>
  313.         <div id="dialog-relacion-{{ routeClassName }}" title="Definir elemento"></div>
  314.     {% endblock %}
  315.     {% block botones_form %}
  316.         <div class="row">
  317.             <div class="col-xs-12">
  318.                 <div class="hr hr-8 hr-dotted"></div>
  319.             </div>
  320.         </div>
  321.     {% endblock %}
  322.     {% block end_form %}
  323.         {{ form_end(form) }}
  324.     {% endblock %}
  325. {% endblock formulario_content %}