yes.

The first view, lets call it formula. 

for this example, just a tiny button with a pencil on it

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


It calls the controler called 'formula_general'

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
)# 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)




in the new view (formula _general.load) just showing the form and nothing 
else (don't extend layout.html) :
<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> 

Here you show the form (in this example Its a one field form, plus a Cancel 
button if the user decides not to edit. Change is showed instantly.

In the event that the users clic on 'cancel', then I created a controller 
just for that, called 'nada'   (spanish for 'nothing')
That controller just returns nothing, thus hiding the form (it could be 
done via jquery though. I just find it easier to use a controller:


 


# turns screen or div blank (for when user clics  on 'cancel'


def nada():
    return ''








On Wednesday, July 29, 2015 at 6:34:30 PM UTC-5, Alex Glaros wrote:
>
> Hi Jorge,
>
> are there two views?  view and new-view (formula _general)?
>
> thanks,
>
> Alex
>

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