Well there is the widget on Web2pySlices (which I believe is the one in the 
Cookbook).  Sadly that doesn't seem to work.  However,  if I put this in my 
HTML,  I don't seem to need a widget at all,  so maybe  that's better.  I 
mean I already have the multiselect function there,  so it's only one extra 
line to that.  I guess I'd better test it a little more though.

<script>
  $(document).ready(
    function(){
     $('[multiple]').multiSelect();
     $('form input:checkbox[name*="gallery_tag_id"]').attr('name', 
'tag_id');
  });
</script>

BTW I also had some trouble with the default widget which adds extra lines. 
 On occasions it gave tickets complaining about the data format.  I guess 
no one really uses that one.


On Saturday, 14 April 2012 14:29:00 UTC+1, rochacbruno wrote:
>
> You need to create a custom widget and then:
>
> db.gallery.tag_id.widget = mycustomwidget
>
> or use the web2py mult select widget that ships with plugin_wiki.
>
> http://zerp.ly/rochacbruno
> Em 14/04/2012 07:50, "villas" <villa...@gmail.com> escreveu:
>
>> Hi All,  I have just spent a few frustrating hours with the jQuery 
>> Multi-Select widget:
>> http://www.abeautifulsite.net/blog/2008/04/jquery-multiselect/ 
>>
>> For this field:
>>   db.define_table('gallery', Field('tag_id','list:reference tag')
>>
>> it renders for example this HTML element:
>>    <label class="checked">
>>      <input type="checkbox" checked="checked" value="1"   
>>  name="gallery_tag_id[]">
>>      MyTagName
>>   </label>
>>
>> Note:  name="gallery_tag_id[]"   does not work (I mean does not save on 
>> submission).
>>
>> I need this instead:  name="tag_id"
>>
>> So, what to do?  For now I put this script into my form to fix it:
>>
>> <script>
>>     $("form").submit(function() {
>>       $("form input:checkbox").attr('name', 'tag_id');
>>     });
>> </script>
>>
>> However,  this is a a bit of a hack,  so someone might have a better 
>> idea?  I can't believe I'm the first to have the problem,  so I think I'm 
>> missing something...
>>
>> Regards,
>> David
>>
>

Reply via email to