Maria, if you really want to you can build the entire form in the view with 
good old HTML. 

   1. An example set of "sentence", "meaning" and word "forms" may be 
   helpful - sounds like you're probably doing some sort of translation thing 
   or maybe it is a quiz?
   2. You'll need to add <form></form> tags to what you've included in your 
   example; just the fields and the submit button aren't enough
   3. you need to give your <select> a name attribute so you can refer to 
   the field later when processing the submission in the controller
      - You'll want to do your naming such that you can figure out which 
      text each returned <select> field value is actually referring to. It 
sounds 
      like you're going to have multiple on a page so I'd suggest naming them 
      with a format like <select name="text_{{=row.id}}">...</select> so that 
      later in your controller you can loop through all the fields submitted, 
      they should be in request.post_vars, and parse back out exactly what text 
      in the database the chosen word form goes to
   4. In your sample code every single <option> is going to have value="cc" 
   you want <option value = "{{=cc}}"> so the value is different for each 
   option
   5. You do not need a <br> after each <option></option> (and when you do 
   actually need a break use the self closing <br /> form)
   6. Remember to VALIDATE the incoming data to make sure that it is 
   actually legitimate! If you use FORM() this is taken care of for you, 
   without it it is up to you to make sure that the text ID provided is 
   actually in the database and that the chosen word form is actually a valid 
   choice for that particular text.

~Brian

On Wednesday, July 9, 2014 4:26:37 PM UTC-5, Maria Levchenko wrote:
>
> Sorry for novice question, but I can't handle it myself.
>
> Is there any possibility to update database from view without creating a 
> form in controller?
> I have a table in database with fields:
> - sentence (a sentence)
> - meaning (one word)
> - forms (list of words)
>
> And I have to ask user to select one word from "forms" that connect to 
> "meaning" (and show him a whole sentence).
>
> This is my view:
> {{for row in texts:}}
>     {{=row.sentences}}: {{=row.meaning}}<br>
>     {{for ff in row.forms:}}
>             {{if len(ff)>0:}}
>                    {{c=ff.split()}}<br>
>     <select> {{for cc in c:}} <option value = "cc">{{=cc}}</option> <br> 
> {{pass}}</select><br>
> {{pass}}
> {{pass}}
> {{pass}}
>
> <input type="submit">
>
> So i have several "select" fields on page and one button "submit".
> I want to insert in database (or update the rows) (with user's click on 
> button): sentence - meaning - selected form (from list).
> Can I do it or it's imposible?
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to