javascriptjqueryajaxsymfonysymfony-sonata

Get id of field input in sonata using Javascript


I use symfony and sonataAdminBundle, in my ProductAdmin Class I have a form with many input type : And i like to get the Id of one of this input called 'prixAchat' : with inspect element I see that sonata generate an auto prefix value before the id like this : s5988300197635_prixAchat so

So I tried to use this code :

prixAchat = document.getElementById('form [id$="_prixAchat"]').value

But always the result is null

Someone can help me please ?


Solution

  • You only want to get input? I think the code should be prixAchat = $('input [id$="_prixAchat"]').val()