This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

maxDubovsky
maxDubovsky

Hi,

I have an issue with saving repeater fields in frontend. Idea is to let user save his social accounts in a json format, and in backend display in the repeater widget. Everything seems to work fine but saved values in database are with slashes.

$userData = UserM::where('id', '=', $user->id)->first();
$jj = json_encode($data['User']['social_media']);
$userData->social_media = $jj;
$userData->save();

Then I check database I see this:

"{\"1\":{\"social_media\":\"123\",\"social_data\":\"456\"},\"2\":{\"social_media\":\"qwe\",\"social_data\":\"rty\"}}"

Then I save same from backend I'm getting this:

{"1":{"social_media":"123","social_data":"456"},"2":{"social_media":"qwe","social_data":"rty"}}

Using spripslashes is not helping: $userData->social_media = stripslashes($jj); Any ideas ?

Last updated

maxDubovsky
maxDubovsky

Because the social_media is jsonable there was no need to encode it. I just passed the array and it worked ! Solved.

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.