M
M
Michael2019-08-31 21:35:34
Yii
Michael, 2019-08-31 21:35:34

How to get city name instead of id?

Hello everybody! Please tell me how to display the name of the city instead of the identifier in the database and how to write the identifier correctly. To select a city in the input, I use the yii2-klard widget , the name of the city is displayed normally. After submitting the form, the identifier 2147483647 is stored in the database regardless of the selected city, which may correspond to some city, but this is not accurate. The question is how to save the correct id and then, when displaying, for example, in view, display the name of the city instead of id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-08-31
@Bally

Read klard's documentation.
1. Getting the name can be done through api.
2. You can also store information about cities in your city table where your id and klard_id vk_id name will be stored
3. Another option is to store the city name and id of Klarl in the record.
It is best to use the second option.
The meaning is this. You search through the Ajax city form field at Klard. Next, before saving the record, see if there is such a city in your database. If there is, then we simply pull out the id; if not, then we create a new city according to the klard data and get your city id already.
But I strongly advise against storing the ID of the cladrus and getting the name of the city by api. So you depend on the Klard system. If something happens to them, it will be difficult for you to recover. At best, you simply will not load the name of the city.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question