Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #907 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

widgets.TableForm shows labels for widgets that should be "label-less"

Reported by: godoy Owned by: anonymous
Priority: normal Milestone: 1.0b1
Component: TG Widgets Version: 0.9a6
Severity: major Keywords:
Cc:

Description

I've already reported that on the trunk mailing list ( http://groups.google.com.br/group/turbogears-trunk/browse_thread/thread/5cc1e68556648266/4bc2b2c039055819?q=r1484&rnum=1#4bc2b2c039055819) but I'm duplicating this here.

This still happens with current version on 1.0 branch (r1513).


Hi!

I have a form where I created some buttons and fieldsets and placed them inside a TableForm?. Today, with r.1484 the names of those started appearing on the first column of the form, even though I specified 'labem = ""' for them.

Anyone else seeing this bug?

Code example:

class WidgetsCurvaCalibracao(widgets.WidgetsList):
    botao_criar_tabela = widgets.Button(
        label = '',
        attrs = dict(onclick =
"monta_tabela_curva_calibracao(getElement('form_pontos_curva'))",
        value = _(u"Criar tabela de calibração"),),)
    tabela_calibracao = widgets.FieldSet(label = '')
    botao_calcular_curva = widgets.Button(
        label = '',
        attrs = dict( onclick =
"curva_calibracao(getElement('form_pontos_curva'))",
        value = _(u"Calcular curva de calibração"),),)
    mensagem = widgets.FieldSet(label = '')

formulario_preparacao_resultados_toxicologia = widgets.TableForm(
    fields = (WidgetsCurvaCalibracao())
    )

Output:

>>> formulario_preparacao_resultados_toxicologia.render()

'<FORM METHOD="post" CLASS="tableform" NAME="form">\n        \n        <TABLE
CELLPADDING="2" CELLSPACING="0" BORDER="0">\n            <TR CLASS="even">\n                
<TH>\n                    <LABEL CLASS="fieldlabel"
FOR="botao_criar_tabela">Botao_criar_tabela</LABEL>\n                </TH>\n                
<TD>\n                    <INPUT NAME="botao_criar_tabela"
ONCLICK="monta_tabela_curva_calibracao(getElement(\'form_pontos_curva\'))"
TYPE="button" CLASS="button" VALUE="Criar tabela de calibra\xc3\xa7\xc3\xa3o"
ID="botao_criar_tabela">\n                    \n                    \n                    
\n                </TD>\n            </TR>\n            <TR CLASS="odd">\n                
<TH>\n                    <LABEL CLASS="fieldlabel"
FOR="tabela_calibracao">Tabela_calibracao</LABEL>\n                </TH>\n                
<TD>\n                    <FIELDSET CLASS="fieldset"
ID="tabela_calibracao">\n        \n        \n        \n    </FIELDSET>\n                    
\n                    \n                </TD>\n            </TR>\n            
<TR CLASS="even">\n                <TH>\n                    <LABEL
CLASS="fieldlabel" FOR="botao_calcular_curva">Botao_calcular_curva</LABEL>\n                
</TH>\n                <TD>\n                    <INPUT
NAME="botao_calcular_curva"
ONCLICK="curva_calibracao(getElement(\'form_pontos_curva\'))" TYPE="button"
CLASS="button" VALUE="Calcular curva de calibra\xc3\xa7\xc3\xa3o"
ID="botao_calcular_curva">\n                    \n                    \n                    
\n                </TD>\n            </TR>\n            <TR CLASS="odd">\n                
<TH>\n                    <LABEL CLASS="fieldlabel"
FOR="mensagem">Mensagem</LABEL>\n                </TH>\n                
<TD>\n                    <FIELDSET CLASS="fieldset" ID="mensagem">\n        
\n        \n        \n    </FIELDSET>\n                    \n                    
\n                </TD>\n            </TR>\n            <TR>\n                
<TD>\xc2\xa0</TD>\n                <TD>\n                <INPUT TYPE="submit"
CLASS="submitbutton">\n                \n                </TD>\n            
</TR>\n        </TABLE>\n    </FORM>' 

I would expect that a button had no label. The same for a fieldset with a declared empty label...

Today I found out that if I have just one space as the label, then it is hidden as it should be...

Isn't there a way to make this the default behavior for, at least, the button widget?

So, exemplifying, this produces a label:

    botao_criar_tabela = widgets.Button(
        attrs = dict(onclick="monta_tabela_curva_calibracao(getElement('form_pontos_curva'))",
        value = _(u"Criar tabela de calibração"),),
        )

as does this:

    botao_criar_tabela = widgets.Button(
        attrs = dict(onclick="monta_tabela_curva_calibracao(getElement('form_pontos_curva'))",
        value = _(u"Criar tabela de calibração"),),
        label = '',
        )

But this hides the undesirable label:

    botao_criar_tabela = widgets.Button(
        attrs = dict(onclick="monta_tabela_curva_calibracao(getElement('form_pontos_curva'))",
        value = _(u"Criar tabela de calibração"),),
        label = ' ',
        )

(Note one single whitespace inside the quotes for the label attribute.)

I consider this a "major" defect because this appears on the UI and fixing it is not so obvious... As I said it didn't happen somewhere near and before r1484.

Change History

comment:1 Changed 13 years ago by michele

The fix is very simple, name is a property that when set also sets the label to uppercase (while I don't quite like this thing), the problem here is that using a WidgetsList? name will be set hence the label is going to be overridden.

I'm going to commit a fix soon.

comment:2 Changed 13 years ago by michele

Should be fixed in r1514.

comment:3 Changed 13 years ago by godoy

  • Status changed from new to closed
  • Resolution set to fixed

The fix allowd me to pass an empty label to remove the auto-generated one. Thanks, I believe this is more intuitive.

We should think about ways to special case some things... I don't see the need to put a label before a button implicitly (explicitly you might give some warning or whatever but I believe that this is the exception, not the label-less button...)

Note: See TracTickets for help on using tickets.