[web2py] Re: SQLFORM.grid custom labels in edit form for each row
But... LABEL have some bug: http://code.google.com/p/web2py/issues/detail?id=566 On 16 Gru, 23:32, Anthony abasta...@gmail.com wrote: In your table definition, you can specify a 'label' argument for each field, and I think that can be whatever you want (e.g., an IMG tag, etc.). db.define_table('mytable', Field('myfield', label=IMG(_src=URL('static','img/myimage.png' Haven't tried it, but hopefully should work. Anthony On Friday, December 16, 2011 5:10:53 PM UTC-5, brushek wrote: Hello, I would like to have images instead of text (or text AND image) in each label for row, when I click edit in form generated by SQLFORM.grid. How to do this in easiest way ? Regards brushek
[web2py] Re: SQLFORM.grid custom labels in edit form for each row
The bug isn't with LABEL, it's with SQLFORM.search_menu, which tries to translate field.label without first converting to a string in case the label is an HTML helper. Should be an easy fix, but for now, you can do: label=str(IMG(...)) or label=IMG(...).xml() either of which will convert the HTML helper to a string, so it won't cause an error with the translator. Also, note that you shouldn't need the LABEL wrapper -- in SQLFORMs, the labels are automatically wrapped in a LABEL(). Anthony On Saturday, December 17, 2011 10:32:36 AM UTC-5, brushek wrote: But... LABEL have some bug: http://code.google.com/p/web2py/issues/detail?id=566 On 16 Gru, 23:32, Anthony abas...@gmail.com wrote: In your table definition, you can specify a 'label' argument for each field, and I think that can be whatever you want (e.g., an IMG tag, etc.). db.define_table('mytable', Field('myfield', label=IMG(_src=URL('static','img/myimage.png' Haven't tried it, but hopefully should work. Anthony On Friday, December 16, 2011 5:10:53 PM UTC-5, brushek wrote: Hello, I would like to have images instead of text (or text AND image) in each label for row, when I click edit in form generated by SQLFORM.grid. How to do this in easiest way ? Regards brushek
[web2py] Re: SQLFORM.grid custom labels in edit form for each row
The bug isn't with LABEL, it's with SQLFORM.search_menu, which tries to translate field.label without first converting to a string in case the label is an HTML helper. Should be an easy fix, but for now, you can do: label=str(IMG(...)) or label=IMG(...).xml() None of this soulutions works :(. I mean, the app doesn't crash, but I can see the text: img alt=Woda src=/sdadmin/static/img_towary/1.png / in label of row, but no image, it isn't that what I want. I tried: Field('tw1','integer',label=str(IMG(_alt='Woda',_src=URL('static','img_towary/ 1.png', and: Field('tw1','integer',label=IMG(_alt='Woda',_src=URL('static','img_towary/ 1.png')).xml()), either of which will convert the HTML helper to a string, so it won't cause an error with the translator. Indeed, but as You can see above, the output isn't image. Also, note that you shouldn't need the LABEL wrapper -- in SQLFORMs, the labels are automatically wrapped in a LABEL(). I need LABEL to make label with text AND image, and it works in: /app/default/planetysurowce/edit/gk_planety/1 but not in: /app/default/planetysurowce where grid is computed. Anyway, thanks Anthony, I think (as You said) it will be quick fix, and all the stuff will work :) regards brushek
[web2py] Re: SQLFORM.grid custom labels in edit form for each row
Sorry, forgot that the label will get escaped. Anyway, there is now a fix in trunk. On Saturday, December 17, 2011 4:58:49 PM UTC-5, brushek wrote: The bug isn't with LABEL, it's with SQLFORM.search_menu, which tries to translate field.label without first converting to a string in case the label is an HTML helper. Should be an easy fix, but for now, you can do: label=str(IMG(...)) or label=IMG(...).xml() None of this soulutions works :(. I mean, the app doesn't crash, but I can see the text: img alt=Woda src=/sdadmin/static/img_towary/1.png / in label of row, but no image, it isn't that what I want. I tried: Field('tw1','integer',label=str(IMG(_alt='Woda',_src=URL('static','img_towary/ 1.png', and: Field('tw1','integer',label=IMG(_alt='Woda',_src=URL('static','img_towary/ 1.png')).xml()), either of which will convert the HTML helper to a string, so it won't cause an error with the translator. Indeed, but as You can see above, the output isn't image. Also, note that you shouldn't need the LABEL wrapper -- in SQLFORMs, the labels are automatically wrapped in a LABEL(). I need LABEL to make label with text AND image, and it works in: /app/default/planetysurowce/edit/gk_planety/1 but not in: /app/default/planetysurowce where grid is computed. Anyway, thanks Anthony, I think (as You said) it will be quick fix, and all the stuff will work :) regards brushek
[web2py] Re: SQLFORM.grid custom labels in edit form for each row
In your table definition, you can specify a 'label' argument for each field, and I think that can be whatever you want (e.g., an IMG tag, etc.). db.define_table('mytable', Field('myfield', label=IMG(_src=URL('static','img/myimage.png' Haven't tried it, but hopefully should work. Anthony On Friday, December 16, 2011 5:10:53 PM UTC-5, brushek wrote: Hello, I would like to have images instead of text (or text AND image) in each label for row, when I click edit in form generated by SQLFORM.grid. How to do this in easiest way ? Regards brushek
[web2py] Re: SQLFORM.grid custom labels in edit form for each row
Thank You, Anthony. It was... so easy!!! I was looking for some very strange and wierd solutions, big + for You :). regards brushek On 16 Gru, 23:32, Anthony abasta...@gmail.com wrote: In your table definition, you can specify a 'label' argument for each field, and I think that can be whatever you want (e.g., an IMG tag, etc.). db.define_table('mytable', Field('myfield', label=IMG(_src=URL('static','img/myimage.png' Haven't tried it, but hopefully should work. Anthony On Friday, December 16, 2011 5:10:53 PM UTC-5, brushek wrote: Hello, I would like to have images instead of text (or text AND image) in each label for row, when I click edit in form generated by SQLFORM.grid. How to do this in easiest way ? Regards brushek