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 <[email protected]>

> 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 <[email protected]> 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/AAAAAAAAHFk/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

Reply via email to