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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>No problem at all.  There may be another way to do it without hiding fields but I’m not sure since we want every field param sent to <code>handle_event("validate"...</code> on each keystroke (or after x milliseconds or onBlur if you set the debounce) so you can feed them all to the changeset.  Also you want every field sent to your “save” event.</p>
<p>In order to figure out how it all worked I had to use <code>IO.inspect()</code> a lot to study the <code>%Changeset{}</code> struct and <code>%Form{}</code> struct and how they change in response to events calling the related functions in the modules.</p>
<p>Also, I was looking at your <code>Order</code> module and not sure if you want to persist this as a DB table but you may want to use <code>Ecto.Schema</code> here instead of relying on schemaless changesets since right now it validates but doesn’t persist.  A good pattern for LV forms can be found in the official examples here: <a href="https://github.com/chrismccord/phoenix_live_view_example/blob/master/lib/demo_web/live/user_live/new.ex" rel="noopener nofollow ugc">LV Form Examples</a> where in the <code>handle_event("save"...</code> you simply call the context function to persist (which validates it again) then pattern match on the result.  If it’s <code>{:ok, user}</code> then it worked and you redirect with flash but if <code>{:error, changeset}</code> is returned then you can display the errors.</p>
<p>Hope this helps!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="153436" 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/liveview-multistep-forms-wizards-field-validation/27309/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-153436" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="153436"
                     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="202276" data-post-id="202276">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I was able to follow the similar multi-step form guide with success after changing the <code>&lt;%= if @current_step == 1 do %&gt; &lt;% end %&gt;</code> lines in my <code>new.html.leex</code> template to:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"># Using Tailwind CSS
&lt;div class="&lt;%= unless @current_step == 1, do: "hidden" %&gt;"&gt;
  # form fields for step 1 here
&lt;/div&gt;

&lt;div class="&lt;%= unless @current_step == 2, do: "hidden" %&gt;"&gt;
  # form fields for step 2 here
&lt;/div&gt;

&lt;div class="&lt;%= unless @current_step == 3, do: "hidden" %&gt;"&gt;
  # form fields for step 3 here
&lt;/div&gt;
</code></pre>
<p>This then allows the form inputs to not be reset when the Live View switches between steps.</p>
<p>I also applied <code>IO.inspect</code> to verify that my changeset wasn’t removing my previous inputs and it works!</p>
<p><img src="https://forum.elixirforum.com/images/emoji/apple/heart.png?v=15" title=":heart:" class="emoji only-emoji" alt=":heart:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="202276" data-batch-url="/posts/batch_likers">
                        1
                      </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/liveview-multistep-forms-wizards-field-validation/27309/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-202276" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="202276"
                     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="202362" data-post-id="202362">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I Think that the problem is using</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;%= form_for ... %&gt;
&lt;%= if step == 1 %&gt;
</code></pre>
<p>Explain: When you are using if and it is not true you don’t have the fields on your html page</p>
<p>you have to use it like this</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;%= form_for ... %&gt;
&lt;div class='&lt;%= if @step == 1, do: "hidden" %&gt;'&gt;
....
&lt;/div&gt;
&lt;div class='&lt;%= if @step == 2, do: "hidden" %&gt;'&gt;
....
&lt;/div&gt;

&lt;% end %&gt;
</code></pre>
<p>by doing that the HTML file will contains all the fields but it will show only on the exact step</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="202362" 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/liveview-multistep-forms-wizards-field-validation/27309/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-202362" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="202362"
                     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="202436" data-post-id="202436">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Maybe don’t use an <code>&lt;input type="submit"/&gt;</code> on the continue button? <code>&lt;button/&gt;</code> should work fine. Or if you do want to use the <code>&lt;input type="submit"/&gt;</code> you should be able to pattern match on the value. You can also have <code>&lt;button type="submit" value="continue"&gt;Continue&lt;/button&gt;</code> and <code>&lt;button type="submit" value="submit"&gt;Submit&lt;/button&gt;</code></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="202436" data-batch-url="/posts/batch_likers">
                        1
                      </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/liveview-multistep-forms-wizards-field-validation/27309/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-202436" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="202436"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="202555" data-post-id="202555">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yup, turns out needed to explicitly set <code>type="button"</code> on my <code>&lt;button&gt;&lt;/button&gt;</code> fields. This then allows me to go back to using <code>phx-click</code>.</p>
<p>I shared Medium post on it, here’s the <a href="https://coretheory.medium.com/how-to-part-2-swap-registration-flow-to-a-live-view-with-phx-gen-auth-multi-step-form-25371540fce1?sk=a67a1773f4ddfb7d7bbd1dd2866199ca" rel="noopener nofollow ugc">friend link</a>.</p>
<p>Thank you! <img src="https://forum.elixirforum.com/images/emoji/apple/blush.png?v=15" title=":blush:" class="emoji" alt=":blush:" loading="lazy" width="20" height="20"><img src="https://forum.elixirforum.com/images/emoji/apple/heart.png?v=15" title=":heart:" class="emoji" alt=":heart:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="202555" 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/liveview-multistep-forms-wizards-field-validation/27309/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-202555" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="202555"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="202564" data-post-id="202564">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Glad it helped.</p>
<p>I recommend that you don’t delete your post, because futures visitors will not understand what I meant in my previous comment, even if they are facing the same issue as you did. Better make a note in the comment to mention the other approach you took.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="202564" data-batch-url="/posts/batch_likers">
                        1
                      </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/liveview-multistep-forms-wizards-field-validation/27309/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-202564" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="202564"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="202569" data-post-id="202569">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><img src="https://forum.elixirforum.com/images/emoji/apple/blush.png?v=15" title=":blush:" class="emoji" alt=":blush:" loading="lazy" width="20" height="20"><img src="https://forum.elixirforum.com/images/emoji/apple/+1.png?v=15" title=":+1:" class="emoji" alt=":+1:" loading="lazy" width="20" height="20">  I’ll try to undelete the post when the action wait period is over.</p>
<p>The Medium post gives more detail on why you need to set the <code>type="button"</code>.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="202569" 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/liveview-multistep-forms-wizards-field-validation/27309/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-202569" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="202569"
                     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>