new.html.twig
10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
{% extends 'base_app.html.twig' %}
{% block body %}
{% form_theme form 'bootstrap_3_horizontal_layout.html.twig' %}
<h1>PlanificacionSeccion creation</h1>
{{ form_start(form) }}
{{ form_row(form.seccion) }}
{{ form_row(form.idtemaUc) }}
<ul class="contenido" data-prototype="{{ form_widget(form.contenido.vars.prototype)|e('html_attr') }}">
</ul>
<ul class="objetivoEspecifico" data-prototype="{{ form_widget(form.objetivoEspecifico.vars.prototype)|e('html_attr') }}">
</ul>
<ul class="estrategia" data-prototype="{{ form_widget(form.estrategia.vars.prototype)|e('html_attr') }}">
</ul>
<ul class="evaluacion" data-prototype="{{ form_widget(form.evaluacion.vars.prototype)|e('html_attr') }}">
</ul>
<input type="submit" value="Create" />
{{ form_end(form) }}
<ul>
<li>
<a href="{{ path('ceapp_docente_planificacion_index') }}">Back to the list</a>
</li>
</ul>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
var $collectionHolder;
// setup an "add a tag" link
var $addEspecificoLink = $('<a href="#" class="add_especifico_link">Añadir Objetivos Especificos</a>');
var $addContenidoLink = $('<a href="#" class="add_contenido_link">Añadir conceptos</a>');
var $addEstrategiaLink = $('<a href="#" class="add_estrategia_link">Añadir estrategias</a>');
var $addEvaluacionLink = $('<a href="#" class="add_evaluacion_link">Añadir Evaluaciones</a>');
var $RemoveContenidoLink = $('<a href="#" class="remove_contenido_link">Quitar Conceptos</a>');
var $newLinkLiContenido = $('<li></li>').append($addContenidoLink);
var $newLinkLiEspecifico = $('<li></li>').append($addEspecificoLink);
var $newLinkLiEstrategia = $('<li></li>').append($addEstrategiaLink);
var $newLinkLiEvaluacion = $('<li></li>').append($addEvaluacionLink);
jQuery(document).ready(function() {
// Get the ul that holds the collection of tags
$contenidoHolder = $('ul.contenido');
$especificoHolder = $('ul.objetivoEspecifico');
$estrategiaHolder = $('ul.estrategia');
$evaluacionHolder = $('ul.evaluacion');
// add the "add a tag" anchor and li to the tags ul
$contenidoHolder.append($newLinkLiContenido);
$especificoHolder.append($newLinkLiEspecifico);
$estrategiaHolder.append($newLinkLiEstrategia);
$evaluacionHolder.append($newLinkLiEvaluacion);
// count the current form inputs we have (e.g. 2), use that as the new
// index when inserting a new item (e.g. 2)
$contenidoHolder.data('index', $contenidoHolder.find(':input').length);
$especificoHolder.data('index', $especificoHolder.find(':input').length);
$estrategiaHolder.data('index', $estrategiaHolder.find(':input').length);
$evaluacionHolder.data('index', $evaluacionHolder.find(':input').length);
$addContenidoLink.on('click', function(e) {
// prevent the link from creating a "#" on the URL
e.preventDefault();
// add a new tag form (see next code block)
addContenidoForm($contenidoHolder, $newLinkLiContenido);
});
$addEspecificoLink.on('click', function(e) {
// prevent the link from creating a "#" on the URL
e.preventDefault();
// add a new tag form (see next code block)
addEspecificoForm($especificoHolder, $newLinkLiEspecifico);
});
$addEstrategiaLink.on('click', function(e) {
// prevent the link from creating a "#" on the URL
e.preventDefault();
// add a new tag form (see next code block)
addEstrategiaForm($estrategiaHolder, $newLinkLiEstrategia);
});
$addEvaluacionLink.on('click', function(e) {
// prevent the link from creating a "#" on the URL
e.preventDefault();
// add a new tag form (see next code block)
addEvaluacionForm($evaluacionHolder, $newLinkLiEvaluacion);
});
function addContenidoForm($contenidoHolder, $newLinkLiContenido) {
// Get the data-prototype explained earlier
var prototype = $contenidoHolder.data('prototype');
// get the new index
var index = $contenidoHolder.data('index');
// Replace '$$name$$' in the prototype's HTML to
// instead be a number based on how many items we have
var newFormContenido = prototype.replace(/__name__/g, index);
// increase the index with one for the next item
$contenidoHolder.data('index', index + 1);
// Display the form in the page in an li, before the "Add a tag" link li
var $newFormLiContenido = $('<li></li>').append(newFormContenido);
// also add a remove button, just for this example
$newFormLiContenido.append('<a href="#" class="remove-tag">x</a>');
$newLinkLiContenido.before($newFormLiContenido);
// handle the removal, just for this example
$('.remove-tag').click(function(e) {
e.preventDefault();
$(this).parent().remove();
return false;
});
}
function addEspecificoForm($especificoHolder, $newLinkLiEspecifico) {
// Get the data-prototype explained earlier
var prototype = $especificoHolder.data('prototype');
// get the new index
var index = $especificoHolder.data('index');
// Replace '$$name$$' in the prototype's HTML to
// instead be a number based on how many items we have
var newFormEspecifico = prototype.replace(/__name__/g, index);
// increase the index with one for the next item
$especificoHolder.data('index', index + 1);
// Display the form in the page in an li, before the "Add a tag" link li
var $newFormLiEspecifico = $('<li></li>').append(newFormEspecifico);
// also add a remove button, just for this example
$newFormLiEspecifico.append('<a href="#" class="remove-tag">x</a>');
$newLinkLiEspecifico.before($newFormLiEspecifico);
// handle the removal, just for this example
$('.remove-tag').click(function(e) {
e.preventDefault();
$(this).parent().remove();
return false;
});
}
function addEstrategiaForm($estrategiaHolder, $newLinkLiEstrategia) {
// Get the data-prototype explained earlier
var prototype = $estrategiaHolder.data('prototype');
// get the new index
var index = $estrategiaHolder.data('index');
// Replace '$$name$$' in the prototype's HTML to
// instead be a number based on how many items we have
var newFormEstrategia = prototype.replace(/__name__/g, index);
// increase the index with one for the next item
$estrategiaHolder.data('index', index + 1);
// Display the form in the page in an li, before the "Add a tag" link li
var $newFormLiEstrategia = $('<li></li>').append(newFormEstrategia);
// also add a remove button, just for this example
$newFormLiEstrategia.append('<a href="#" class="remove-tag">x</a>');
$newLinkLiEstrategia.before($newFormLiEstrategia);
// handle the removal, just for this example
$('.remove-tag').click(function(e) {
e.preventDefault();
$(this).parent().remove();
return false;
});
}
function addEvaluacionForm($evaluacionHolder, $newLinkLiEvaluacion) {
// Get the data-prototype explained earlier
var prototype = $evaluacionHolder.data('prototype');
// get the new index
var index = $evaluacionHolder.data('index');
// Replace '$$name$$' in the prototype's HTML to
// instead be a number based on how many items we have
var newFormEvaluacion = prototype.replace(/__name__/g, index);
// increase the index with one for the next item
$evaluacionHolder.data('index', index + 1);
// Display the form in the page in an li, before the "Add a tag" link li
var $newFormLiEvaluacion = $('<li></li>').append(newFormEvaluacion);
// also add a remove button, just for this example
$newFormLiEvaluacion.append('<a href="#" class="remove-tag">x</a>');
$newLinkLiEvaluacion.before($newFormLiEvaluacion);
// handle the removal, just for this example
$('.remove-tag').click(function(e) {
e.preventDefault();
$(this).parent().remove();
return false;
});
}
});
</script>
{% endblock %}