I work around my problem like this :

Add this little script in the view

<script>
jQuery(document).ready(function(){
    jQuery('.input_wrapper').has('.error').addClass("inputError"); // Add
bootstrap class "inputError" to .input_wrapper div when there is error.
Note .input_wrapper div is only there for field with bootstrap "add-on"
class, since it would have required to alter SQLFORM to set a
.input_wrapper div to every input field I think...
    jQuery('.w2p_fw').has('.error').addClass("control-group error"); // Add
bootstrap class "control-group error" to .w2p_fw when there is error
    jQuery('.w2p_fw').each(function(){
        $(this).find('.error_wrapper').appendTo(this); // I move the
.error_wrapper div at the end of the .w2p_fw for each .w2p_fw
    });
});
</script>

Write custom widget :

def app_date_widget(field, value, placeholder='YYYY-MM-DD'):
    return DIV(INPUT(_name=field.name,
                 _id="%s_%s" % (field._tablename, field.name),
                 _class=field.type,
                 _value=value,
                 _placeholder=T(placeholder),
                 requires=field.requires),
                 SPAN(I(_class='icon-calendar'), _class='add-on'),
                 _class='input_wrapper input-append' # input-append is a
bootstrap class required to make work add-on we create the input_wrapper
for this
                 )

And set the widget to my table field :

    Field('test_date','date',
        notnull=True,
        requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty')),
            IS_DATE(format=T('%Y-%m-%d'),error_message=T('valid date of
format : YYYY-MM-DD'))],
        required=True,
        widget=app_date_widget
        )



On Mon, Oct 29, 2012 at 11:47 AM, Richard <ml.richard.vez...@gmail.com>wrote:

> Hello,
>
> I am searching for a way to use bootstrap input-append and add-on.
>
> <div class="w2p_fw">
> <input class="date" id="table_date" name="date" placeholder="YYYY-MM-DD"
> type="text" value="">
> <span class="add-on"><i class="icon-calendar"></i></span>
> </div>
>
>
> The problem is that when the error trigger the error get between the input
> and the span like this :
>
> <div class="w2p_fw input-append control-group error">
> <input class="date invalidinput inputError" id="table_date" name="date"
> placeholder="YYYY-MM-DD" type="text" value="">
> * <div class="error_wrapper">*
> * <div class="error" id="date__error" style="display: inline-block;
> ">can't be empty</div>*
> * </div>*
> <span class="add-on"><i class="icon-calendar"></i></span>
> </div>
>
> Even if I put the input and span in a div :
>
> <div class="w2p_fw">
> * <div class="input-append control-group error">*
> <input class="date invalidinput inputError" id="table_date" name="date"
> placeholder="YYYY-MM-DD" type="text" value="">
> * <div class="error_wrapper">*
> * <div class="error" id="date__error" style="display: inline-block;
> ">can't be empty</div>*
> * </div>*
> <span class="add-on"><i class="icon-calendar"></i></span>
> * </div>*
> </div>
>
>
> I see no way to fix that except refactoring html.py INPUT class near line
> 1793, but I am not sure if it will cause a backward incompatibility...
>
> Richard
>
> --
>
>
>
>

-- 



Reply via email to