web2py does not provide an out-of-the-box solution for this case. If you
create a model like this:
db.define_table('config2', ...)
db.define_table('phone',
Field('config2', 'reference config2'),
Field('service_type', 'string'),
Field('phone_number', 'string'))
Then you could use SQLFORM.smartgrid to display/navigate the two tables and
add records to each. However, you won't get a single view or form showing
both the config2 fields and the phone fields at the same time. Otherwise,
you will have to create a custom form to handle the input, and then write
some custom code on the back end to handle inserting records into the two
tables.
Note, as an alternative to the two-table model above, you could include a
single "phone" field in config2 with a "json" type, storing the list of
phones as JSON. This would still require custom code to handle the form UI
and post processing before insert.
Anthony
On Friday, November 13, 2015 at 2:15:05 AM UTC-5, at wrote:
>
>
> Initially I was thinking the same, but results are not as desired:
>
>
> db.define_table('phone',
> Field('service_type', 'string'),
> Field('phone_number', 'string'))
>
> db.define_table('config2',
> Field('cell_phones', 'list:reference phone'), label=T('Dispatchers
> Cell Phone #s'))
>
> Thanks,
> AT
>
> On Friday, 13 November 2015 11:09:02 UTC+5, 黄祥 wrote:
>>
>> sorry, perhaps you can use list:reference type of field for that.
>> - create table that store cell phone number and it's service type
>> - then define config table that have list:reference to the table that
>> store cell phone number and service type.
>> - another thing is if you want to add new cell phone number and service
>> type that not recorded yet and want to remain in that page form, consider
>> use the modal that have form to input new data cell phone number and
>> service type
>>
>> best regards,
>> stifan
>>
>> On Friday, November 13, 2015 at 12:36:54 PM UTC+7, at wrote:
>>>
>>> Hi Stifan,
>>>
>>> Thank you for your prompt reply. This will not give the desired result.
>>> After your suggested change, I get:
>>>
>>>
>>> What I need is service-type and phone-number side-by-side, so when I add
>>> a record it should add one service-name and one corresponding phone number.
>>>
>>> Best Regards,
>>> AT
>>>
>>> On Friday, 13 November 2015 09:56:32 UTC+5, 黄祥 wrote:
>>>>
>>>> pardon me, not sure what do you mean with free-text field? is it same
>>>> like cello phone type of field (list:string)
>>>> e.g.
>>>> db.define_table('config',
>>>> Field('cell_phones', 'list:string', label=T('Dispatchers Cell Phone
>>>> #s') ),
>>>> Field('service_provider_name', 'list:string', label=T('Service
>>>> Provider Name') )
>>>> )
>>>>
>>>> best regards,
>>>> stifan
>>>>
>>>
--
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].
For more options, visit https://groups.google.com/d/optout.