[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Luis Goncalves
Yes ... too many  :(

Here's a 'simple' one:

The database table definition, which I use as a form for input:

 

  db.define_table('scorecard',
  Field('offense1', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),
  Field('defense1', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),

 

  Field('offense2', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),
  Field('defense2', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),

 

  Field('fifth', db.player, requires=IS_IN_DB( db, 'player.id', 
'%(name)s', zero=T('choose one')) ),

 

  Field('score1', 'integer', requires=IS_IN_SET([1, 2, 3, 4, 
5],zero=None)),
  Field('score2', 'integer', requires=IS_IN_SET([1, 2, 3, 4, 
5],zero=None)),

 

  Field('start', 'datetime', readable=False, writable=False),
  Field('finish', 'datetime', readable=False, writable=False),
  Field('single', 'boolean', readable=False, writable=False)) # single 
game during round-robin rotate play, or part of a game-set-match

 I would like this to display something like: 


https://lh3.googleusercontent.com/-043w1FYNTj8/Tipod6h9_zI/HFk/0eX4V6S0Uf0/scorecard.png

The input is a scorecard for a game.  Two teams with two players each,  and 
a fifth person that will  play the next game.

The user defines who is playing the current game, and who is sitting out. 
 When the game is over, they select the scores.

On 'submit', the teams and scores are recorded, and the form is shown again, 
with a suggested line-up for the next game

(but the user can alter the line-up if he wants). 

 

 


In the controller:


def rotate_5_man(): 


form = SQLFORM( db.scorecard )

# retrieve previous player positions.

# pre-fill form with some suggestions 

 

 

if form.accepts( .. )


# record score,  

# figure out how to rotate players for next game


return dict(form=form)


In the view,  rotate_5_man.html :


{{extend 'layout.html'}}

{{=form}}



So right now, the display of the form is quite rudimentary 
(each item gets shown in order, listed vertically).

Is there a simple way to get the above layout instead? 

Preferably done with minimal additional python/web2py/html, 
but via CSS instead!

 

Thanks!!!
Luis. 

 

 


 

 

 

 

 

 

 

 

 



[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Anthony
What's wrong with this method - 
http://web2py.com/book/default/chapter/07#Custom-forms - you can put the 
form widgets wherever you want? Or specifically, how would 
better/smarter/proper use of the #id table-field entries help? What would 
you like to see in the rendered form HTML that would enable you to do what 
you want with just CSS?
 
Anthony

On Saturday, July 23, 2011 2:33:54 AM UTC-4, Luis Goncalves wrote:

 Yes ... too many  :( 

 Here's a 'simple' one:

  The database table definition, which I use as a form for input:

  

db.define_table('scorecard',
   Field('offense1', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),
   Field('defense1', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),

  

Field('offense2', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),
   Field('defense2', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),

  

Field('fifth', db.player, requires=IS_IN_DB( db, 'player.id', 
 '%(name)s', zero=T('choose one')) ),

  

Field('score1', 'integer', requires=IS_IN_SET([1, 2, 3, 4, 
 5],zero=None)),
   Field('score2', 'integer', requires=IS_IN_SET([1, 2, 3, 4, 
 5],zero=None)),

  

Field('start', 'datetime', readable=False, writable=False),
   Field('finish', 'datetime', readable=False, writable=False),
   Field('single', 'boolean', readable=False, writable=False)) # single 
 game during round-robin rotate play, or part of a game-set-match

   I would like this to display something like: 


  
 https://lh3.googleusercontent.com/-043w1FYNTj8/Tipod6h9_zI/HFk/0eX4V6S0Uf0/scorecard.png

 The input is a scorecard for a game.  Two teams with two players each,  and 
 a fifth person that will  play the next game.

  The user defines who is playing the current game, and who is sitting out. 
  When the game is over, they select the scores.

  On 'submit', the teams and scores are recorded, and the form is shown 
 again, with a suggested line-up for the next game

  (but the user can alter the line-up if he wants). 

   

   


  In the controller:


  def rotate_5_man(): 


  form = SQLFORM( db.scorecard )

  # retrieve previous player positions.

  # pre-fill form with some suggestions 

   

   

  if form.accepts( .. )


   # record score,  

   # figure out how to rotate players for next game


  return dict(form=form)


  In the view,  rotate_5_man.html :


  {{extend 'layout.html'}}

  {{=form}}



 So right now, the display of the form is quite rudimentary 
 (each item gets shown in order, listed vertically).

 Is there a simple way to get the above layout instead? 

 Preferably done with minimal additional python/web2py/html, 
 but via CSS instead!

  

 Thanks!!!
 Luis. 

  

   


  

  

   



   

   

   

   

   



Re: [web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Luis Goncalves
I am just a beginner with CSS/HTML,  and so maybe I have a misconceived idea
of what CSS can/should do and the right way to use it.

Naively, I thought that I could use the #id=table-field entries in CSS to
control placement/shape of the form elements, and not need to change much
more in the controller or the view?

It seems that if I have to use custom forms, then I might as well not even
bother with using SQLFORM --  it's pretty much like building the form piece
by piece in the view?

thanks,
Luis.

On Fri, Jul 22, 2011 at 11:42 PM, Anthony abasta...@gmail.com wrote:

 What's wrong with this method -
 http://web2py.com/book/default/chapter/07#Custom-forms - you can put the
 form widgets wherever you want? Or specifically, how would
 better/smarter/proper use of the #id table-field entries help? What would
 you like to see in the rendered form HTML that would enable you to do what
 you want with just CSS?

 Anthony

 On Saturday, July 23, 2011 2:33:54 AM UTC-4, Luis Goncalves wrote:

 Yes ... too many  :(

 Here's a 'simple' one:

  The database table definition, which I use as a form for input:



db.define_table('scorecard',
   Field('offense1', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),
   Field('defense1', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('offense2', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),
   Field('defense2', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('fifth', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('score1', 'integer', requires=IS_IN_SET([1, 2, 3, 4,
 5],zero=None)),
   Field('score2', 'integer', requires=IS_IN_SET([1, 2, 3, 4,
 5],zero=None)),



Field('start', 'datetime', readable=False, writable=False),
   Field('finish', 'datetime', readable=False, writable=False),
   Field('single', 'boolean', readable=False, writable=False)) # single
 game during round-robin rotate play, or part of a game-set-match

   I would like this to display something like:



 https://lh3.googleusercontent.com/-043w1FYNTj8/Tipod6h9_zI/HFk/0eX4V6S0Uf0/scorecard.png

 The input is a scorecard for a game.  Two teams with two players each,
  and a fifth person that will  play the next game.

  The user defines who is playing the current game, and who is sitting
 out.  When the game is over, they select the scores.

  On 'submit', the teams and scores are recorded, and the form is shown
 again, with a suggested line-up for the next game

  (but the user can alter the line-up if he wants).






  In the controller:


  def rotate_5_man():


  form = SQLFORM( db.scorecard )

  # retrieve previous player positions.

  # pre-fill form with some suggestions





  if form.accepts( .. )


   # record score,

   # figure out how to rotate players for next game


  return dict(form=form)


  In the view,  rotate_5_man.html :


  {{extend 'layout.html'}}

  {{=form}}



 So right now, the display of the form is quite rudimentary
 (each item gets shown in order, listed vertically).

 Is there a simple way to get the above layout instead?

 Preferably done with minimal additional python/web2py/html,
 but via CSS instead!



 Thanks!!!
 Luis.



























Re: [web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Martín Mulone
Take a look to this:

http://martin.tecnodoc.com.ar/default/post/2011/04/13/2_hacking-web2py-sqlform-part-1

I have to make the part 2, to show more complex css form with sqlforms.

2011/7/23 Luis Goncalves l...@vision.caltech.edu

 I am just a beginner with CSS/HTML,  and so maybe I have a misconceived
 idea of what CSS can/should do and the right way to use it.

 Naively, I thought that I could use the #id=table-field entries in CSS to
 control placement/shape of the form elements, and not need to change much
 more in the controller or the view?

 It seems that if I have to use custom forms, then I might as well not even
 bother with using SQLFORM --  it's pretty much like building the form piece
 by piece in the view?

 thanks,
 Luis.


 On Fri, Jul 22, 2011 at 11:42 PM, Anthony abasta...@gmail.com wrote:

 What's wrong with this method -
 http://web2py.com/book/default/chapter/07#Custom-forms - you can put the
 form widgets wherever you want? Or specifically, how would
 better/smarter/proper use of the #id table-field entries help? What would
 you like to see in the rendered form HTML that would enable you to do what
 you want with just CSS?

 Anthony

 On Saturday, July 23, 2011 2:33:54 AM UTC-4, Luis Goncalves wrote:

 Yes ... too many  :(

 Here's a 'simple' one:

  The database table definition, which I use as a form for input:



db.define_table('scorecard',
   Field('offense1', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),
   Field('defense1', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('offense2', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),
   Field('defense2', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('fifth', db.player, requires=IS_IN_DB( db, 'player.id',
 '%(name)s', zero=T('choose one')) ),



Field('score1', 'integer', requires=IS_IN_SET([1, 2, 3, 4,
 5],zero=None)),
   Field('score2', 'integer', requires=IS_IN_SET([1, 2, 3, 4,
 5],zero=None)),



Field('start', 'datetime', readable=False, writable=False),
   Field('finish', 'datetime', readable=False, writable=False),
   Field('single', 'boolean', readable=False, writable=False)) #
 single game during round-robin rotate play, or part of a game-set-match

   I would like this to display something like:



 https://lh3.googleusercontent.com/-043w1FYNTj8/Tipod6h9_zI/HFk/0eX4V6S0Uf0/scorecard.png

 The input is a scorecard for a game.  Two teams with two players each,
  and a fifth person that will  play the next game.

  The user defines who is playing the current game, and who is sitting
 out.  When the game is over, they select the scores.

  On 'submit', the teams and scores are recorded, and the form is shown
 again, with a suggested line-up for the next game

  (but the user can alter the line-up if he wants).






  In the controller:


  def rotate_5_man():


  form = SQLFORM( db.scorecard )

  # retrieve previous player positions.

  # pre-fill form with some suggestions





  if form.accepts( .. )


   # record score,

   # figure out how to rotate players for next game


  return dict(form=form)


  In the view,  rotate_5_man.html :


  {{extend 'layout.html'}}

  {{=form}}



 So right now, the display of the form is quite rudimentary
 (each item gets shown in order, listed vertically).

 Is there a simple way to get the above layout instead?

 Preferably done with minimal additional python/web2py/html,
 but via CSS instead!



 Thanks!!!
 Luis.




























-- 
 http://martin.tecnodoc.com.ar


Re: [web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-23 Thread Anthony
On Saturday, July 23, 2011 3:06:13 AM UTC-4, Luis Goncalves wrote: 

 I am just a beginner with CSS/HTML,  and so maybe I have a misconceived 
 idea of what CSS can/should do and the right way to use it. 

 Naively, I thought that I could use the #id=table-field entries in CSS to 
 control placement/shape of the form elements, and not need to change much 
 more in the controller or the view?

 
Yes, you should be able to (to some extent, depending on exactly what you 
want to do). If you use formstyle='divs', you'll get a set of divs with a 
consistent scheme of CSS classes and ids to identify the different form 
elements. Beyond that, is there something additional you think web2py could 
be doing to facilitate the kind of CSS-based customization you want to do. 
What output should web2py be generating that would enable you to achieve the 
form formatting you want purely via CSS?
 

 It seems that if I have to use custom forms, then I might as well not even 
 bother with using SQLFORM --  it's pretty much like building the form piece 
 by piece in the view?

 
SQLFORM (and FORM, to a lesser extent) does a lot more than just build the 
form HTML for you. It also handles validation, error message display, CSRF 
and double submission protection (via a _formkey hidden field), form 
pre-population for updates, database insertion, etc. Using the 
form.custom.widgets is also easier than manually building all the HTML for 
each field widget.
 
Anthony
 


[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-22 Thread Luis Goncalves
Thanks, Anthony!  

I still haven't figured it out completely (mostly because I don't know very 
much about CSS and someone else is dealing with that part of the project). 

Thanks!
Luis.


[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-22 Thread Anthony
Also, if you need more control, see 
http://web2py.com/book/default/chapter/07#Custom-forms.

On Friday, July 22, 2011 9:59:24 PM UTC-4, Luis Goncalves wrote:

 Thanks, Anthony!  

 I still haven't figured it out completely (mostly because I don't know very 
 much about CSS and someone else is dealing with that part of the project). 

 Thanks!
 Luis.



[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-22 Thread Anthony
On Friday, July 22, 2011 10:29:25 PM UTC-4, Luis Goncalves wrote: 

 Thanks!   Also, I think we need to make better/smarter/proper use of the 
 #id table-field entries of each field!

 
Do you have an example?
 
Anthony


[web2py] Re: SQLFORM with divs or ordered lists instead of tables (for easier control with CSS)

2011-07-18 Thread Anthony
See the 'formstyle' argument: 
http://web2py.com/book/default/chapter/07?search=formstyle

On Monday, July 18, 2011 11:04:10 PM UTC-4, Luis Goncalves wrote:


 Tables are hard to control in CSS, is there a way to have SQLFORM use divs 
 or lists instead?

 I have seen many(!) posts about redefining SQLFORM and making it more 
 flexible, but I'm not sure if any conclusion has been reached.

 Thanks,
 Luis.