Thank yOU for looking into this. Will you post a follow-up to this thread 
or should I monitor the google code issue list re this issue?

On Monday, August 5, 2013 12:38:50 AM UTC+2, Massimo Di Pierro wrote:
>
> Your first solution should also have worked. I will look into it.
>
> On Sunday, 4 August 2013 16:40:57 UTC-5, step wrote:
>>
>> Answering my own question, with jQuery I found a way to display just a 
>> single error message div for a list:string type field. I added this code to 
>> the view:
>>     {{if grid.update_form or grid.create_form:}}
>>     {{#hide all list:string error divs but the first one, and move it 
>> before the data}}
>>     <script type="text/javascript">
>>     $(document).ready(function() {
>>         var f=['email','phone']; //list:strings
>>         for (var i=0; i<f.length; i++) {
>>             $('#person_'+f[i]+' .error_wrapper').each(function(i) {
>>                 if (i==0) $(this).siblings().first().before($(this));
>>                 else this.style.display='none';
>>             });
>>         }
>>     });
>>     </script>
>>     {{pass}}
>>     {{=grid}}
>>
>>
>>
>> On Saturday, August 3, 2013 12:52:16 AM UTC+2, step wrote:
>>>
>>> is it possible to display just one error message of a list:string input 
>>> right after the last input control, using SQLFORM.grid?
>>>
>>> With SQLFORM,grid create/update form, when a list:string field with 
>>> validators has errors it should be possible to hide the error display on 
>>> all list inputs but the last one. At least that's how I interpret the 
>>> current ListWidget code in sqlform.py
>>>         nvalue = value or ['']
>>>         items = [LI(INPUT(_id=_id, _class=_class, _name=_name,
>>>                           value=v, hideerror=k < len(nvalue) - 1,
>>>                           requires=requires),
>>>                     **attributes) for (k, v) in enumerate(nvalue)]
>>> so hideerror=True for all input items but the last one. Effectively, 
>>> this should display a single error message after the last string of the 
>>> list. How nice, but it doesn't seem to work, and the form repeats the same 
>>> error message under each string of the list - 100 times if the list:string 
>>> comprises 100 elements.
>>> I'm not sure where the hideerror attribute gets reset in the chain. I 
>>> check its value in function _translate, and it's always false, even when I 
>>> add this code after the above code in the ListWidget - for the sake of 
>>> investigating this issue.
>>>         for i in items:
>>>             for e in i.elements:
>>>                 e.attributes['hideerror'] = True
>>> hideerror is still == False for all self.components in _translate() 
>>> while I'd expect it to be True for components that correspond to my 
>>> list:string inputs.
>>>     def _traverse(self, status, hideerror=False):
>>> # zip zip...
>>>
>>>         # for input, textarea, select, option
>>>         # deal with 'value' and 'validation'
>>>
>>>         name = self['_name']
>>>         print name, self['hideerror'] # this always prints False
>>>
>>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to