Input datas... Please help


I have this dynamic page (1).

The titles are connected to my “Artists” database

The table below is connected to my “Titles” database

This is my “titles imput” page (2). When I enter all fields, it works, except the “Artist” field (3)

How to make that when I enter the name of the artist on my page (2), it is integrated in the good dynamic page “Artist” (5)

Please help me. Please. What am I supposed to do? What code was used? How to integrate it?

Thank you in advance for your answers. I’m desperate.

up

Nobody to help me ?

Up

Really need help ! :frowning:

Hi,
I’m truly sorry for the delay. Firstly, note that the grey columns are created automatically when creating a dynamic page and based on the settings of it. You cannot edit it. Moreover, the images are a bit blurry so I was not quit sure what you were referring. Can you please send us the site URL so that I can have a look?

Thanks,
Tal.

https://karlbertrand43.wixsite.com/listkara/titres-title

Only the field “Artistes” don’t work. You can make try if you want

Up

Hi Karl,

if i understand your question correct, you have a form ‘AJOUTS TITRES’ in which you want to add a new item but one of the input is a reference to the artist table?
so it should be a drop down of artists right?
in the collection in the db, although you see in the editor the title of the artists, what’s really being kept is the _id of the other collection.

Shlomi

The names of the artists were previously created in a separate database, to have their own dynamic page

What I want is that when I enter the artist’s name in the “Artist” field (first picture),

I want it to automatically enter it in the database (second image) in the “Artist” field. (The “Artist” field in the database is a drop-down menu)

So far, when I go through my add title page, it leaves the “Artist” field empty. Everything else fills up normally. So in the database, I have to manually enter the names of the artists

(Sorry about my English, I’m French)

Hi Karl,

ok, i understand. as i wrote above, in the db collection editing you have in the editor there is a UI trick, you insert the artist name ‘Artiste’ because it is your collection primary field but it actually saves the ‘ID’ of the collection record in the db. this is why it will not work just like that in the form

please also think about spelling mistake and validations, in case the input artist does not appear in the db. please also keep in mind that currently you can also create artists in the collection with an identical name (different ID)
so in the form you need to create some kind of a search on the artist collection the user can choose from, keep the and then before submitting the form set the ID value in the artiste field of your Titres collection

hope i was able to explain the issue,
Shlomi

Thanks for your answer, but I didn’t get it all: p

What do you mean, I’m putting this in place? Can you give me a practical example?

run this code below in your page and see in preview console what you get:

import wixData from 'wix-data';

$w.onReady(async function () {
 let artist = await wixData.get('Titres','59e91716-caf6-4249-b0cc-31bf6ac34c8a');
    console.log(artist);
    console.log(artist.artiste)
});

Shlomi

Don’t worrk :confused:

there’s something I don’t have to do right. Do you have a wix address that I send you a copy of the site? Maybe it’ll be easier

Hey,

i am able to see your site’s code, running it this is what i get:
{“_id”:“59e91716-caf6-4249-b0cc-31bf6ac34c8a”,“_owner”:“51b05dc5-5c08-4a3e-9875-6fe08f218e63”,“_createdDate”:“2018-07-24T14:24:55.768Z”,“_updatedDate”:“2018-07-24T14:26:45.558Z”,“title”:“Medley (Live "La Dernière Danse" 2017)”,“inputArtist”:“Michel Sardou”,“artiste”:“e735c657-ad4c-423e-9741-b82f773fbc99”,“annee”:“2017”,“live”:“Live”,“languePrincipale”:“Français”}

e735c657-ad4c-423e-9741-b82f773fbc99

but my point is that the actual data you should save in the db is the ID, not the name. so when using a form with an artist name as a reference field, it should contain the ID of the referenced artist. this is why the current form is not working for you.

Shlomi

I’m completely lost :stuck_out_tongue: If someone wants to make the correction, send me an email, and I will send you a copy of the site. (karlbertrand43@gmail.com)

Karl,

please see similar discussion here:

Shlomi

Where am I wrong ?

$w.onReady( function () {
//TODO: write your page related code here…

});

import wixData from ‘wix-data’;

export function button1_click(event, $w) {

wixData.query('Titres') 
.eq('Artiste', $w('#input14').value) 
    .find()  
    .then(res => { 

let firstItem = res.items[0];
let toInsert = {
“Artiste”: firstItem,
“Title”: $w(“#input14”).value
};
wixData.insert(“Titres”, toInsert)
.then((results) => {
let item = results;
})
. catch ((err) => {
let errorMsg = err;
});
});
}

Hi,

if you will add a console.log(firstItem) of the item you load from the db, you will see that this is the entire json object. you just need to thake the _id form this object to be put in the ‘Artiste’ field

Shlomi

???