:) yes you are right. If you are attach to this example, and this js,
you can make read only input i think with writable=False and
readable=True. And add check like IS_FLOAT and put default value like
default=0 to lat and long.

On 9 ago, 22:51, Rob <r...@rmdashr.com> wrote:
> If anyone can write a tutorial using bad programming practices, it's
> Microsoft!
>
> I could port that portion of the code that converts address to LAT/LON
> values using this (server 
> side):http://web2py.com/book/default/chapter/12#Geocoding
>
> But like I said, I'm just trying to do a straight port of the
> NerdDinner app.
>
> Thanks!
>
> On Aug 9, 6:39 pm, "Martin.Mulone" <mulone.mar...@gmail.com> wrote:
>
>
>
> > You can do this in that way, or you can do that in correct way. Good
> > programming dont hide or populate values in the client (javascript).
> > The correct way is to populate the lat and long in server side. I dont
> > know what values you need it. If you dont have any other way nobody
> > prohibit to do that.
>
> > On 9 ago, 20:46, Rob <r...@rmdashr.com> wrote:
>
> > > It's probably lame, but I'm attempting to port NerdDinner to web2py
> > > (http://nerddinnerbook.s3.amazonaws.com/Part11.htm), in this section
> > > they have some javascript code that says this:
>
> > > //... do a bunch of stuff to get lat/lon from user entered address ...
> > > //If we've found exactly one place, that's our address.
> > > if (points.length === 1) {
> > >         $("#Dinners_Latitude").val(points[0].Latitude);
> > >         $("#Dinners_Longitude").val(points[0].Longitude);
> > >     }
>
> > > Which queries bing map service for lat/lon of a user entered address.
> > > The JS snippet places the result from the query in 2 hidden input
> > > boxes and their controller stores them in the DB.
>
> > > If I set readable/writable to False, they won't display when the page
> > > is rendered... thus the JS will have no place to put the results.
>
> > > Ideally, I'd have the controller do the work of figuring out the lat/
> > > lon, but I'm just doing a port and got suck at this point here.
>
> > > Am I making sense?
>
> > > Thanks,
> > > Rob
>
> > > On Aug 9, 3:07 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > You can make something like this work you should not. It is a security
> > > > vulnerability to have a editable hidden field because it does not
> > > > prevent the client from editing. In web2py you should never need
> > > > something like this. Just make the field invisible:
>
> > > > db.Dinners.Latitude.readable=False
> > > > db.Dinners.Latitude.writable=False
>
> > > > On Aug 9, 3:12 pm, Rob <r...@rmdashr.com> wrote:
>
> > > > > after 
> > > > > reading:https://groups.google.com/group/web2py/browse_frm/thread/bd7b06b759c9...
>
> > > > > It looks like what I can do is this:
> > > > > db.Dinners.Latitude.widget=lambda
> > > > > field,value:SQLFORM.widgets.StringWidget.widget(field,value,_type="hidden")
>
> > > > > Will this work?  I'll test when I get home tonight.
>
> > > > > On Aug 7, 10:21 pm, Rob <r...@rmdashr.com> wrote:
>
> > > > > > I have a model that has a 'Address', 'Lat' and "Lon' field.  When 
> > > > > > the
> > > > > > user enters an address, some javascript currently populates the 
> > > > > > 'Lat'
> > > > > > and 'Lon' fields and they get inserted into the DB via crud.create()
> > > > > > or crud.update().
>
> > > > > > How do I hide these fields from the user, but allow the JS to insert
> > > > > > the correct values?  Idealy, I would like to turn these fields from
> > > > > > input fields to hidden fields.
>
> > > > > > Possible?
>
> > > > > > just for reference:
> > > > > > model:
> > > > > > db.define_table('Dinners',
> > > > > >     Field('Address', requires=IS_NOT_EMPTY()),
> > > > > >     Field('Latitude', 'double'), # <== I want this to be a hidden
> > > > > > field
> > > > > >     Field('Longitude', 'double')) # <== I want this to be a hidden
> > > > > > field
>
> > > > > > controller:
> > > > > > def Create():
> > > > > >     crud.settings.formstyle='table2cols'
> > > > > >     form = crud.create(db.Dinners)
> > > > > >     return dict(form=form)
>
> > > > > > view:
> > > > > > {{=form}}
>
> > > > > > Thanks!

Reply via email to