I do it adding a button like you did, but

<https://lh3.googleusercontent.com/-K3818KhWrTY/VbZRasM0_ZI/AAAAAAAAAJk/CNE1qCy52ak/s1600/salchicha1.png>



view:
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>


controller:

<https://lh3.googleusercontent.com/-rAThavnT4DU/VbZRg6O3aYI/AAAAAAAAAJs/wa4qSZeSPyM/s1600/salchicha2.png>
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)




in the new view (formula _general)
<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 ''




On Saturday, July 25, 2015 at 9:35:46 PM UTC-5, Alex Glaros wrote:
>
> not sure how to describe this question, but is there a way to avoid 
> writing a separate edit page for a data item by using the same page that 
> displays it, but having a button submitted that says "edit", which enables 
> a conditional statement to edit the data on the same page?
>
> Normally I have a "edit" button on a view page (view_profile_data), which 
> takes user to a separate view page (edit_profile_data).
>
> To avoid creating the edit_profile_data page, is it possible to have a 
> conditional in the view_profile_data page like this:
>
> {{if edit_button is clicked:}}
>     {{=form}}
> {{pass}}
> Does anyone do it like that or does everyone send user to separate edit 
> page?  I guess I'm wondering if there are short-cuts.
>
> thanks,
>
> Alex Glaros
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to