Created
May 19, 2013 22:37
-
-
Save jburgui/5609336 to your computer and use it in GitHub Desktop.
new estudio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% form_theme form _self %} | |
{% block _Estudio_parteEstudio_entry_row %} | |
{% spaceless %} | |
<div class="span3 well parte"> | |
<button type="button" class="close">×</button> | |
{{ form_label(form) }} | |
{{ form_errors(form) }} | |
{{ form_widget(form) }} | |
</div> | |
{% endspaceless %} | |
{% endblock %} | |
{% block _Estudio_partesEstudio_entry_label %} | |
{% endblock %} | |
{% block gestion %} | |
<div id="frame"> | |
<h1>Crear Estudio</h1> | |
<script> | |
{#--------------------------------------------#} | |
function addTagForm(collectionHolder) { | |
// Get the data-prototype explained earlier | |
var prototype = collectionHolder.data('prototype'); | |
// get the new index | |
var index = collectionHolder.data('index'); | |
// Replace '__name__' in the prototype's HTML to | |
// instead be a number based on how many items we have | |
var newForm = prototype.replace(/__name__/g, index); | |
// increase the index with one for the next item | |
collectionHolder.data('index', index + 1); | |
// Display the form in the page in an li, before the "Add a address" link li | |
var $newFormLi = $('<div></div>').append(newForm); | |
collectionHolder.append($newFormLi); | |
} | |
// Get the div that holds the collection of addresses | |
var collectionHolder = $('div.partes'); | |
// setup an "add a address" link | |
var $newLinkLi = $('<a href="#" class="btn btn-mini btn-info add_address_link"><i class="icon-plus icon-white"></i> Añadir una dirección</a>'); | |
$(function(){ | |
// add the "add a address" anchor and li to the addresses div | |
collectionHolder.parent().append($newLinkLi); | |
// count the current form inputs we have (e.g. 2), use that as the new | |
// index when inserting a new item (e.g. 2) | |
collectionHolder.data('index', collectionHolder.find(':input').length); | |
$newLinkLi.on('click', function(e) { | |
// prevent the link from creating a "#" on the URL | |
e.preventDefault(); | |
// add a new address form (see next code block) | |
addTagForm(collectionHolder); | |
}); | |
$(document).on('click', '.close', function(){ | |
$(this).closest('.parte').fadeOut(500, function() { | |
$(this).remove(); | |
}); | |
}); | |
}); | |
</script> | |
<div class="row"> | |
<div class="span12"> | |
<form id="crear" action="{{ path('estudio_create') }}" method="post" novalidate> | |
{{ form_widget(form) }} | |
<div class="form-actions"> | |
<button class="cargando" type="submit">Crear</button> | |
</div> | |
</form> | |
</div> | |
</div> | |
<ul class="record_actions"> | |
<li> | |
<a href="#" onclick="cargarEnGestion('{{ path('estudio') }}')"> | |
Volver a la lista | |
</a> | |
</li> | |
</ul> | |
<script> | |
//para que el form cargue al filtrar en "gestion" | |
var params= {target:'.gestion'}; | |
$('#crear').ajaxForm(params); | |
//para que los botones del formularios carguen en la ventana "cargando" | |
$(document).ready(function(){ | |
$('.cargando').click(function() { | |
ocultarid('gestion'); | |
mostrarid('cargando'); | |
}); | |
}); | |
</script> | |
<script> | |
//para ocultar la ventana "cargando" | |
ocultarid('cargando'); | |
mostrarid('gestion'); | |
</script> | |
</div> | |
{% endblock %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment