On submission of Edit form, fields not edited at all, the name value of these fields are sent as blank values









up vote
0
down vote

favorite












Brief of what I am doing : Clicks on Edit form and it loads up, it fetches correct values from mongodb collections and displays in three fields of the Edit page.



Below form is displayed on click of 'Edit' button.



<% include ../partials/header %>

<div class="container">

<h1 style="text-align:center">Edit <strong><i>"<%= campground.name %>"</i></strong></h1>
<div style="width:40%; margin:25px auto;">
<form action="/campgrounds/<%= campground._id %>?_method=PUT" method="POST">
<p>campground object : <%= campground %></p>
<div class="form-group row">
<input type="text" class="form-control" placeholder="<%= campground.name %>" name="updatedCampground[name]">
</div>
<div class="form-group row">
<input type="text" class="form-control" placeholder="<%= campground.image %>" name="updatedCampground[image]">
</div>
<div class="form-group row">
<input type="text" class="form-control" placeholder="<%= campground.description %>" name="updatedCampground[description]">
</div>
<div class="form-group row">
<button class="btn btn-lg btn-info btn-block">Submit!</button>
</div>
</form>
<a href="/campgrounds/<%= campground._id %>">Back</a>
</div>
</div>
<% include ../partials/footer %>


POST processing of this form is done in below route :



router.put('/:id', function(req, res)
Campground.findByIdAndUpdate(req.params.id, req.body.updatedCampground, function(error, foundCampground)
console.log("updatedCampground object from the form is", req.body.updatedCampground);
if(error)
console.log("There was some error updating the campground", error);
res.redirect("/campgrounds");

else
res.redirect("/campgrounds/" + foundCampground._id);

);
);


Issue : Two issues I am facing -



1. The fields that are being populated in the Edit form are NOT editable. To be more specific, I click on the field value and cursor just stays at the start of the value and doesn't move to right when I click on right arrow our use mouse to click on any character of the value displayed in the field. To make edits to the field I wanted to, as a workaround I am selecting a random value from the drop down list(browser saved values) of that field and then once that value gets selected in the field box I am making edits on it and then clicking on 'Submit' button. This works fine for that particular field but there is second issue below.



How Edit page looks when populated



2. For the fields in the 'Edit' form that I don't want to edit, on submission of form these fields values goes as blank in the updatedCampground array specified in the 'name' attribute of the Edit form.



What I have verified : The updatedCampground array specified in the 'name' attribute has blank values after submission of form, for the fields that were NOT edited. When Edit form displays the field values are NOT editable.










share|improve this question



























    up vote
    0
    down vote

    favorite












    Brief of what I am doing : Clicks on Edit form and it loads up, it fetches correct values from mongodb collections and displays in three fields of the Edit page.



    Below form is displayed on click of 'Edit' button.



    <% include ../partials/header %>

    <div class="container">

    <h1 style="text-align:center">Edit <strong><i>"<%= campground.name %>"</i></strong></h1>
    <div style="width:40%; margin:25px auto;">
    <form action="/campgrounds/<%= campground._id %>?_method=PUT" method="POST">
    <p>campground object : <%= campground %></p>
    <div class="form-group row">
    <input type="text" class="form-control" placeholder="<%= campground.name %>" name="updatedCampground[name]">
    </div>
    <div class="form-group row">
    <input type="text" class="form-control" placeholder="<%= campground.image %>" name="updatedCampground[image]">
    </div>
    <div class="form-group row">
    <input type="text" class="form-control" placeholder="<%= campground.description %>" name="updatedCampground[description]">
    </div>
    <div class="form-group row">
    <button class="btn btn-lg btn-info btn-block">Submit!</button>
    </div>
    </form>
    <a href="/campgrounds/<%= campground._id %>">Back</a>
    </div>
    </div>
    <% include ../partials/footer %>


    POST processing of this form is done in below route :



    router.put('/:id', function(req, res)
    Campground.findByIdAndUpdate(req.params.id, req.body.updatedCampground, function(error, foundCampground)
    console.log("updatedCampground object from the form is", req.body.updatedCampground);
    if(error)
    console.log("There was some error updating the campground", error);
    res.redirect("/campgrounds");

    else
    res.redirect("/campgrounds/" + foundCampground._id);

    );
    );


    Issue : Two issues I am facing -



    1. The fields that are being populated in the Edit form are NOT editable. To be more specific, I click on the field value and cursor just stays at the start of the value and doesn't move to right when I click on right arrow our use mouse to click on any character of the value displayed in the field. To make edits to the field I wanted to, as a workaround I am selecting a random value from the drop down list(browser saved values) of that field and then once that value gets selected in the field box I am making edits on it and then clicking on 'Submit' button. This works fine for that particular field but there is second issue below.



    How Edit page looks when populated



    2. For the fields in the 'Edit' form that I don't want to edit, on submission of form these fields values goes as blank in the updatedCampground array specified in the 'name' attribute of the Edit form.



    What I have verified : The updatedCampground array specified in the 'name' attribute has blank values after submission of form, for the fields that were NOT edited. When Edit form displays the field values are NOT editable.










    share|improve this question

























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Brief of what I am doing : Clicks on Edit form and it loads up, it fetches correct values from mongodb collections and displays in three fields of the Edit page.



      Below form is displayed on click of 'Edit' button.



      <% include ../partials/header %>

      <div class="container">

      <h1 style="text-align:center">Edit <strong><i>"<%= campground.name %>"</i></strong></h1>
      <div style="width:40%; margin:25px auto;">
      <form action="/campgrounds/<%= campground._id %>?_method=PUT" method="POST">
      <p>campground object : <%= campground %></p>
      <div class="form-group row">
      <input type="text" class="form-control" placeholder="<%= campground.name %>" name="updatedCampground[name]">
      </div>
      <div class="form-group row">
      <input type="text" class="form-control" placeholder="<%= campground.image %>" name="updatedCampground[image]">
      </div>
      <div class="form-group row">
      <input type="text" class="form-control" placeholder="<%= campground.description %>" name="updatedCampground[description]">
      </div>
      <div class="form-group row">
      <button class="btn btn-lg btn-info btn-block">Submit!</button>
      </div>
      </form>
      <a href="/campgrounds/<%= campground._id %>">Back</a>
      </div>
      </div>
      <% include ../partials/footer %>


      POST processing of this form is done in below route :



      router.put('/:id', function(req, res)
      Campground.findByIdAndUpdate(req.params.id, req.body.updatedCampground, function(error, foundCampground)
      console.log("updatedCampground object from the form is", req.body.updatedCampground);
      if(error)
      console.log("There was some error updating the campground", error);
      res.redirect("/campgrounds");

      else
      res.redirect("/campgrounds/" + foundCampground._id);

      );
      );


      Issue : Two issues I am facing -



      1. The fields that are being populated in the Edit form are NOT editable. To be more specific, I click on the field value and cursor just stays at the start of the value and doesn't move to right when I click on right arrow our use mouse to click on any character of the value displayed in the field. To make edits to the field I wanted to, as a workaround I am selecting a random value from the drop down list(browser saved values) of that field and then once that value gets selected in the field box I am making edits on it and then clicking on 'Submit' button. This works fine for that particular field but there is second issue below.



      How Edit page looks when populated



      2. For the fields in the 'Edit' form that I don't want to edit, on submission of form these fields values goes as blank in the updatedCampground array specified in the 'name' attribute of the Edit form.



      What I have verified : The updatedCampground array specified in the 'name' attribute has blank values after submission of form, for the fields that were NOT edited. When Edit form displays the field values are NOT editable.










      share|improve this question















      Brief of what I am doing : Clicks on Edit form and it loads up, it fetches correct values from mongodb collections and displays in three fields of the Edit page.



      Below form is displayed on click of 'Edit' button.



      <% include ../partials/header %>

      <div class="container">

      <h1 style="text-align:center">Edit <strong><i>"<%= campground.name %>"</i></strong></h1>
      <div style="width:40%; margin:25px auto;">
      <form action="/campgrounds/<%= campground._id %>?_method=PUT" method="POST">
      <p>campground object : <%= campground %></p>
      <div class="form-group row">
      <input type="text" class="form-control" placeholder="<%= campground.name %>" name="updatedCampground[name]">
      </div>
      <div class="form-group row">
      <input type="text" class="form-control" placeholder="<%= campground.image %>" name="updatedCampground[image]">
      </div>
      <div class="form-group row">
      <input type="text" class="form-control" placeholder="<%= campground.description %>" name="updatedCampground[description]">
      </div>
      <div class="form-group row">
      <button class="btn btn-lg btn-info btn-block">Submit!</button>
      </div>
      </form>
      <a href="/campgrounds/<%= campground._id %>">Back</a>
      </div>
      </div>
      <% include ../partials/footer %>


      POST processing of this form is done in below route :



      router.put('/:id', function(req, res)
      Campground.findByIdAndUpdate(req.params.id, req.body.updatedCampground, function(error, foundCampground)
      console.log("updatedCampground object from the form is", req.body.updatedCampground);
      if(error)
      console.log("There was some error updating the campground", error);
      res.redirect("/campgrounds");

      else
      res.redirect("/campgrounds/" + foundCampground._id);

      );
      );


      Issue : Two issues I am facing -



      1. The fields that are being populated in the Edit form are NOT editable. To be more specific, I click on the field value and cursor just stays at the start of the value and doesn't move to right when I click on right arrow our use mouse to click on any character of the value displayed in the field. To make edits to the field I wanted to, as a workaround I am selecting a random value from the drop down list(browser saved values) of that field and then once that value gets selected in the field box I am making edits on it and then clicking on 'Submit' button. This works fine for that particular field but there is second issue below.



      How Edit page looks when populated



      2. For the fields in the 'Edit' form that I don't want to edit, on submission of form these fields values goes as blank in the updatedCampground array specified in the 'name' attribute of the Edit form.



      What I have verified : The updatedCampground array specified in the 'name' attribute has blank values after submission of form, for the fields that were NOT edited. When Edit form displays the field values are NOT editable.







      html forms name-attribute form-processing






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 3:15

























      asked Nov 9 at 6:32









      utkarsh-k

      12




      12



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220873%2fon-submission-of-edit-form-fields-not-edited-at-all-the-name-value-of-these-fi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220873%2fon-submission-of-edit-form-fields-not-edited-at-all-the-name-value-of-these-fi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          Edmonton

          Crossroads (UK TV series)