div class="subtitulo"><h3> {{=datos_formula.nombre}} </h3></div><div> <button class="btn" id="formula" title="clic para editar nombre" type="button" onclick="web2py_component('{{=URL('default','formula_general.load')}}', 'panel')"> <i class="icon-pencil"></i></button></div>
<br/>
<div id ="panel" width="100%"></div>
def formula_general():
fields = ['nombre'] record = session.formula
form = SQLFORM(db.formulas, record, fields=fields) request.post_vars.id = session.formula
if form.process().accepted: response.flash = 'actualizado' redirect(request.env.http_web2py_component_location, client_side=True) elif form.errors: response.flash = 'favor revisar'
return dict(form=form)<form action="#" enctype="multipart/form-data" method="post" data-w2p_target="panel"><input type="hidden" name="_formname" value="{{=form.formname}}" /> <input type="hidden" name="_formkey" value="{{=form.formkey}}" />
{{=form.custom.widget.nombre}} {{=form.custom.submit}} <button class="btn" id="cancelar" onclick="web2py_component('{{=URL('default','nada.load')}}', 'panel')"> Cancelar</button># turns screen or div blank (for when user clics on 'cancel'
def nada(): return ''Hi Jorge,are there two views? view and new-view (formula _general)?
<button class="btn" id="formula" title="clic para editar nombre" type="button" onclick="web2py_component('{{=URL('default','formula_general.load')}}', 'panel')"> <i class="icon-pencil"></i></button>
<div id ="panel" width="100%"></div>def formula_general():
fields = ['nombre'] record = session.formula
form = SQLFORM(db.formulas, record, fields=fields)
if form.process().accepted: response.flash = 'actualizado' redirect(request.env.http_web2py_component_location, client_side=True)# Need it to reload the main page after editing fields, so the change are reflected instantly. elif form.errors: response.flash = 'favor revisar'
return dict(form=form)<form action="#" enctype="multipart/form-data" method="post" data-w2p_target="panel"><input type="hidden" name="_formname" value="{{=form.formname}}" /> <input type="hidden" name="_formkey" value="{{=form.formkey}}" />
{{=form.custom.widget.nombre}} {{=form.custom.submit}} <button class="btn" id="cancelar" onclick="web2py_component('{{=URL('default','nada.load')}}', 'panel')"> Cancelar</button>
# turns screen or div blank (for when user clics on 'cancel'
def nada(): return ''is there a way to make the edit button (<i class="icon-pencil"></i>) and other non-editing info temporarily disappear when editing in the form?how would view "know" if in edit mode?
document.getElementById("formula").style.visibility="hidden" ;
<button class="btn" id="formula" title="Click to edit this checklist type" type="button" onclick= document.getElementById("hide_if_editing").style.visibility="hidden" ;"web2py_component('{{=URL('default','formula_general', vars=dict(specificOrganizationID=specificOrganizationID, specificCheckListTypeID=specificCheckListTypeID))}}', 'panel')"> <i class="icon-pencil"></i> Edit this check list type</button>
<div id="hide_if_editing"> <!-------- HIDE IF EDITING ------------------------------------------------------------------------> {{=grid}}</DIV> <!--------------------------------- END OF: HIDE IF EDITING -----------------------------------------------------------> <button class="btn" id="formula" title="Click to edit this checklist type" type="button" onclick= "web2py_component('{{=URL('default','formula_general', vars=dict(specificOrganizationID=specificOrganizationID, specificCheckListTypeID=specificCheckListTypeID)) }}', 'panel')"; document.getElementById("hide_if_editing").style.visibility="hidden"> <i class="icon-pencil"></i> Edit this check list type</button>
okay, changed the order of the statement and now works perfectly, thanks!