Yii Framework Forum: Adding City to Yii2-User extension - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Adding City to Yii2-User extension using Google Places Autocomplete API Rate Topic: -----

#1 User is offline   Benn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 16-January 11
  • Location:Paris

Posted 10 December 2017 - 07:34 PM

Hello all,
I'd like to add a city field to the user profile in Yii2-User using Google Places Autocomplete API.
I've managed to add the field (and hidden fields) to the registration page, I've managed to have the hidden fields populated as they should when a city is selected, but I'm just not clear on how to get everything in the database on submission.
Obviously, I need to have the city be created in the DB if it doesn't exist yet before it's linked to the profile but I'm not sure how to do that.
My relevant code so far is in the following pastebins :

https://pastebin.com/u/Bennd

If anyone could help, that would be amazing.

Thanks

Benn
0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,533
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 11 December 2017 - 04:08 AM

it depends which yii2-user extension you are using, if you are using dektrium/yii2-user you can register event callbacks

https://github.com/d...oller-events.md
0

#3 User is offline   Benn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 16-January 11
  • Location:Paris

Posted 11 December 2017 - 04:24 AM

Thanks ! I am indeed using dektrium/yii2-user. I'm not familiar with these events callbacks, if you have more information, that would be great, otherwise, I'll look into it ;)
0

#4 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,533
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 11 December 2017 - 10:09 AM

here you go the documentation is pretty comprehensive they have a dedicated page for adding custom fields to profile table

https://github.com/d...tration-form.md
0

#5 User is offline   Benn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 16-January 11
  • Location:Paris

Posted 11 December 2017 - 10:20 AM

View Postalrazi, on 11 December 2017 - 10:09 AM, said:

here you go the documentation is pretty comprehensive they have a dedicated page for adding custom fields to profile table

https://github.com/d...tration-form.md


Thanks, I had used that to add (with success :) ) a phone number to the profile :)
I tried using a similar technique for the city, but it's more complicated due to the fact that I need to create a new object in a different table :)
I guess I'll keep looking :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users