javascript - Fill input field, with twig value using jquery -


i've been searching while no luck.

i know question looks mundane, , has plenty (as in hundreds) of answers out in google , here, yet, still problem seems far solved.

i have following problem, need fill input field, value silex variables in twig file.

the form follows:

<span>author: </span> <input type="text" name="author" id="author"  {% if user.getauthorname %}value="{{user.getauthorname}}"{% endif %} /> <span><a href="#" id="filler">use own username</a></span> 

and js code is:

<script>   $(function(){     $('#filler').live('click', function() {       $("#author").val($("#author").text("{{user.getfirstname}} {{user.getlastname}}"));     }); }); </script> 

the problem i'm having is, code works, yet still, when click, fills field with

[object object] 

instead of actual value of 2 variables

i've tried changing hidden field id, , setting variables value, , using .text($("#idfield").val())

still no luck, still fills values

[object object] 

has of idea i'm doing wrong here?

you should remove double declaration:

$("#author").val("{{user.getfirstname}} {{user.getlastname}}"); 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -