It is difficult to understand what you mean, or what you are doing.
Therefore, I am not sure how to help. However, here are a few comments:
- I only used .xml() to print the contents of the var 'form' in the
shell, I wouldn't use it otherwise.
- The code you wrote seems to be valid (I mean it doesn't produce a
ticket), although I do not know where the list 'years' is declared.
- FORM is a low level method to produce forms. If you want to use
server validation (IS_INT_IN_RANGE) then you would probably be better
creating a form with SQLFORM.factory().
- I would recommend that you spend a little more time trying some of
the form examples in the book before adding any complexities of vue.
On Wednesday, 23 September 2020 at 17:02:13 UTC+1 Константин Комков wrote:
> Villlas, yes that variant with .xml() add attribute, but that variant with
> FORM not worked, and I don't know how to add it in FORM.
> def my_func():
>
> form = FORM(DIV(DIV(LABEL('Год:', _for='year'),
>
>
> SELECT(*years, _name='year', _id='year',
> requires=IS_INT_IN_RANGE(request.now.year - 1,
> request.now.year + 1,
>
>
> error_message='Указан
> некорректный год!'),
> _class='form-control', **{'_v-model': 'year'}),
> _class='col-sm-12 col-md-4 col-lg-3'), _class='form-group
> row'))
> return dict(form=form)
>
> P.S. That variant not worked:
> XML(SELECT(*years, _name='year', _id='year', _class='form-control',
> requires=IS_INT_IN_RANGE(request.now.year - 1, request.now.year + 1,
> error_message="Year isn't correct!"), **{'_v-model': 'year'}).xml())
>
>
> среда, 23 сентября 2020 г., 18:41:12 UTC+3 пользователь villas написал:
>
>> Strange, copy and paste lines in the shell...
>>
>> >>> years = ['2020','2021']
>>
>> >>> SELECT(*years, _name='year', _id='year', _class='form-control',
>> requires=IS_INT_IN_RANGE(request.now.year - 1, request.now.year + 1,
>> error_message="Year isn't correct!"), **{'_v-model': 'year'}).xml()
>>
>> '<select class="form-control" id="year" name="year"
>> v-model="year"><option value="2020">2020</option><option
>> value="2021">2021</option></select>'
>>
>>
>>
>> On Wednesday, 23 September 2020 at 12:18:50 UTC+1 Константин Комков wrote:
>>
>>> I do form with fields *year, month* and another some fields which must
>>> be loaded from table in database if year and month != ''.
>>> I know how to make that with vue attributes, but cun't create them
>>> inside function in controller. Villas, your example is the same - not work.
>>> If I add **{'_data-test': 'test'} - when form was generated I have
>>> data-test="test" in select, **{'_v-model': 'year'} -when form was generated
>>> I don't have v-model="year" in select.
>>>
>>> вторник, 22 сентября 2020 г., 20:50:15 UTC+3 пользователь Константин
>>> Комков написал:
>>>
>>>>
>>>> I don't know but it's not working:
>>>>
>>>> SELECT(*years, _name='year', _id='year',
>>>> requires=IS_INT_IN_RANGE(request.now.year - 1, request.now.year + 1,
>>>> error_message="Year isn't correct!'"),
>>>> _class='form-control', **{'_v-model': 'year'})
>>>>
>>>>
>>>>
>>>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/f26fefad-7bbd-401b-a40f-bda095eadb17n%40googlegroups.com.