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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You can also use the <code>name</code> and <code>value</code> attribute for buttons and rely purely on browser behavior to get the value in your LiveView.</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://www.dofactory.com/html/button/name">
  <header class="source">
      <img src="https://www.dofactory.com/favicon.ico" class="site-icon" alt="" width="48" height="48">

      <a href="https://www.dofactory.com/html/button/name" target="_blank" rel="noopener nofollow ugc">dofactory.com</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://www.dofactory.com/html/button/name" target="_blank" rel="noopener nofollow ugc">HTML button name</a></h3>

  <p>In HTML, the name attribute on a  tag assigns a name to the button. This name is used during form submission and as a reference for other purposes.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="266774" data-batch-url="/posts/batch_likers">
                        3
                      </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/live-view-2-submit-buttons-identify-which-one-was-pressed/27219/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-266774" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="266774"
                     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="266789" data-post-id="266789">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m fond of that solution, used it recently here:</p>
<p><a href="https://github.com/lubien/sorteios/blob/main/lib/sorteios_web/templates/session/new.html.heex#L48" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/lubien/sorteios/blob/main/lib/sorteios_web/templates/session/new.html.heex#L48</a></p>
<p><a href="https://github.com/lubien/sorteios/blob/main/lib/sorteios_web/controllers/session_controller.ex#L19" class="onebox" target="_blank" rel="noopener nofollow ugc">https://github.com/lubien/sorteios/blob/main/lib/sorteios_web/controllers/session_controller.ex#L19</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="266789" 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/live-view-2-submit-buttons-identify-which-one-was-pressed/27219/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-266789" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="266789"
                     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="269818" data-post-id="269818">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>that solution only works in a controller, but not in a live-view.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="269818" 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/live-view-2-submit-buttons-identify-which-one-was-pressed/27219/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-269818" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="269818"
                     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="270090" data-post-id="270090">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>here’s my alpine-js workaround to it, in case someone can use it:</p>
<p>(in this case i needed a “test” button to pre-evaluate a form before really submitting it and closing the modal)</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"> &lt;div
      x-data="{
        submitAndTest: function() {
          const field=this.getNextActionField();
          field.value='test';
          document.getElementById('editform').dispatchEvent(new CustomEvent('submit', { bubbles: true }));
          field.value='';
        },
        getNextActionField() {
          const form=this.$el.closest('form');
          const field=form.querySelector('#_next_action_field');
          if(field) {
            return field;
          } else {
              var input = document.createElement('input');
              input.type = 'hidden';
              input.id = '_next_action_field';
              input.name = 'action[name]';
              const newfield=form.appendChild(input);
              return newfield;
          }
        }
      }"
    &gt;
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir">      &lt;.form
        :let={f}
        for={@form}
        as={:fdata}
        phx-change="validate"
        phx-submit="save"
        phx-target={@myself}
        id="editform"
      &gt;
</code></pre>
<pre data-code-wrap="elixir"><code class="lang-elixir">          &lt;div&gt;
            &lt;a x-on:click.stop.prevent="submitAndTest" href="#" &gt;
              Test Filter-Rules
            &lt;/a&gt;
          &lt;/div&gt;
</code></pre>
<p>then, in the live-component you can pattern match for the action parameter alongside your form-data:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def handle_event("save", %{"action" =&gt; %{"name" =&gt; "test"}, "form" =&gt; form}, socket) do
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="270090" 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/live-view-2-submit-buttons-identify-which-one-was-pressed/27219/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-270090" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="270090"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="296444" data-post-id="296444">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mitkins" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mitkins/120/8434_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mitkins
                    <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>Gosh, it’s been a while! The following article was in DockYard’s newsletter today:</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://dockyard.com/blog/2023/07/27/implementing-multiple-submit-buttons-with-liveview">
  <header class="source">

      <a href="https://dockyard.com/blog/2023/07/27/implementing-multiple-submit-buttons-with-liveview" target="_blank" rel="noopener nofollow ugc" title="05:37PM - 27 July 2023">DockYard – 27 Jul 23</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/460;"><img src="https://assets.dockyard.com/dockyard_com/liveview-mulitple-buttons-f5931694-abe3-4eff-93b6-572d66f83c82.webp" class="thumbnail" alt="" width="690" height="460"></div>

<h3><a href="https://dockyard.com/blog/2023/07/27/implementing-multiple-submit-buttons-with-liveview" target="_blank" rel="noopener nofollow ugc">Implementing Multiple Submit Buttons with LiveView</a></h3>

  <p>Learn how to implement multiple buttons for different actions using Phoenix LiveView.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>Please read the article, but in my case this:</p>
<pre data-code-wrap="html"><code class="lang-html">&lt;.form for={@form} phx-submit="save"&gt;
  ...
  
  &lt;button name="save" value="work"&gt;Work&lt;/button&gt;
  &lt;button name="save" value="break"&gt;Break&lt;/button&gt;
&lt;/.form&gt;
</code></pre>
<p>Would work with this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def handle_event("save", %{"save" =&gt; save_type}, socket) do
  # `save_type` will be either "work" or "break"!

  {:noreply, socket}
end
</code></pre>
<p>Much simpler! <img src="https://forum.elixirforum.com/images/emoji/apple/tada.png?v=15" title=":tada:" class="emoji" alt=":tada:" 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="296444" data-batch-url="/posts/batch_likers">
                        10
                      </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/live-view-2-submit-buttons-identify-which-one-was-pressed/27219/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-296444" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="296444"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
    <div class="postbit" id="296446" data-post-id="296446">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It should be mentioned that on older liveview versions this was not possible, the only way you could achieve this before (excluding the abominations where JS is involved) was to declare a <code>a</code> link with value and style it as a button.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="296446" 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/live-view-2-submit-buttons-identify-which-one-was-pressed/27219/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-296446" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="296446"
                     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="296447" data-post-id="296447">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mitkins" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mitkins/120/8434_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mitkins
                    <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>Yes. That’s a fair point. This would have not helped 2019 me</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="296447" 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/live-view-2-submit-buttons-identify-which-one-was-pressed/27219/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-296447" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="296447"
                     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>