<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="149842" data-post-id="149842">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Kurisu" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Kurisu/120/14820_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Kurisu
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Kurisu" data-post="11" data-topic="26640">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kurisu/48/14820_2.png" class="avatar"> Kurisu:</div>
<blockquote>
<p>Then if we use Phoenix <code>form_for</code> helper to generate a form, we don’t have to set the method, just setting the action will be enough for the helper to add the appropriate method to the form. For example <code>Routes.user_path(@conn, :edit, @user)</code> as action will result in a form with POST as method. So personally I don’t worry about this detail. I let Phoenix handle it for me.</p>
</blockquote>
</aside>
<p>Oops the action should be <code>:update</code> here instead of <code>:edit</code> (which is just a GET request to show the form).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="149842" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-changeset-and-form-validation-and-update-using-put/26640/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-149842" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="149842"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="149870" data-post-id="149870">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sd4code" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sd4code
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Post method is best in certain cases where you don’t want a url query string on the location bar, because it hides the internal parameters. This is an application. Not a website. So those XML web developers need to know that xml is a transport language only in applications. So there is no destinations to remote query. I imagine you could get the jsnode to generate something, but it could lead to security exploits.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="149870" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-changeset-and-form-validation-and-update-using-put/26640/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-149870" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="149870"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="150387" data-post-id="150387">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ashok" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ashok
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>In case of add new card I am able to insert the card new details also able to show validation message like for currency if some one tries to enter text input form willl not get submit and shows invalid data error. But in my form all values filled by user got clear instead of showing old values.</p>
<p>Please suggest how can I get form values filled by user instead of showing all fields blank this will help to reduce user rework from filling all values again and again</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="150387" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-changeset-and-form-validation-and-update-using-put/26640/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-150387" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="150387"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="150398" data-post-id="150398">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Kurisu" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Kurisu/120/14820_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Kurisu
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="ashok" data-post="14" data-topic="26640">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/a/ed655f/48.png" class="avatar"> ashok:</div>
<blockquote>
<p>Please suggest how can I get form values filled by user instead of showing all fields blank this will help to reduce user rework from filling all values again and again</p>
</blockquote>
</aside>
<p>Well you have already the path set here:</p>
<aside class="quote no-group" data-username="Kurisu" data-post="2" data-topic="26640">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kurisu/48/14820_2.png" class="avatar"> Kurisu:</div>
<blockquote>
<p>If you don’t already followed <a href="https://hexdocs.pm/phoenix/contexts.html" rel="noopener nofollow ugc">the official guide </a>, please try it</p>
</blockquote>
</aside>
<p>Example of User controller:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def new(conn, _params) do
    changeset = Accounts.change_user(%User{})
    render(conn, "new.html", changeset: changeset)
  end

  def create(conn, %{"user" =&gt; user_params}) do
    case Accounts.create_user(user_params) do
      {:ok, user} -&gt;
        conn
        |&gt; put_flash(:info, "User created successfully.")
        |&gt; redirect(to: Routes.user_path(conn, :show, user))
      {:error, %Ecto.Changeset{} = changeset} -&gt;
        render(conn, "new.html", changeset: changeset)
    end
  end

  def edit(conn, %{"id" =&gt; id}) do
    user = Accounts.get_user!(id)
    changeset = Accounts.change_user(user)
    render(conn, "edit.html", user: user, changeset: changeset)
  end

  def update(conn, %{"id" =&gt; id, "user" =&gt; user_params}) do
    user = Accounts.get_user!(id)

    case Accounts.update_user(user, user_params) do
      {:ok, user} -&gt;
        conn
        |&gt; put_flash(:info, "User updated successfully.")
        |&gt; redirect(to: Routes.user_path(conn, :show, user))
      {:error, %Ecto.Changeset{} = changeset} -&gt;
        render(conn, "edit.html", user: user, changeset: changeset)
    end
  end
</code></pre>
<p>Then the Accounts Context</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def create_user(attrs \\ %{}) do
    %User{}
    |&gt; User.changeset(attrs)
    |&gt; Repo.insert()
  end

  def update_user(%User{} = user, attrs) do
    user
    |&gt; User.changeset(attrs)
    |&gt; Repo.update()
  end

  def change_user(%User{} = user) do
    User.changeset(user, %{})
  end
</code></pre>
<p>For the forms only the action and the page title should be different.<br>
You set <code>Routes.user_path(@conn, :create)</code>  for <code>new</code> form<br>
and You set <code>Routes.user_path(@conn, :update, @user)</code>  for <code>edit</code> form.</p>
<p>If you’re facing the same issue even though you follow this logic maybe it is because you’re nesting complex level of parents and childrens associations in your form ? In this case maybe the below thread I created myself some times ago could help you? Good luck. ^^</p>
<aside class="quote quote-modified" data-post="1" data-topic="11876">
  <div class="title">
    <div class="quote-controls"></div>
    <img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kurisu/48/14820_2.png" class="avatar">
    <div class="quote-title__text-content">
      <a href="https://forum.elixirforum.com/t/please-why-am-i-loosing-child-association-data-when-ecto-changeset-insert-fails/11876" rel="nofollow">Please why am I loosing child association data when ecto changeset insert fails?</a> <a class="badge-category__wrapper " href="/c/questions-help/questions/53" rel="nofollow"><span data-category-id="53" style="--category-badge-color: #C14BFB; --category-badge-text-color: #000000; --parent-category-badge-color: #C14BFB;" data-parent-category-id="171" data-drop-close="true" class="badge-category --style-square --has-parent" title="Elixir Questions / Help"><span class="badge-category__name">Questions</span></span></a>
    </div>
  </div>
  <blockquote>
    Hello ! 
So I have a Client schema that belongs to a User schema, and has one Company schema (optional). 
Here is the Client changeset I’m using with a registration form : 
@doc false
  def create_changeset(%Client{} = client, attrs) do
    client
    |&gt; cast(attrs, [:qualification, :phone])
    |&gt; cast_assoc(:user, with: &amp;User.create_changeset/2)
    |&gt; cast_assoc(:company)
    |&gt; validate_required([:qualification])
    |&gt; unique_constraint(:user_id)
  end

And now here is a Context function th…
  </blockquote>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="150398" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/ecto-changeset-and-form-validation-and-update-using-put/26640/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-150398" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="150398"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>