久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何獲取 Laravel 4 控制器中一系列復選框的值(如

How to get the values for a series of checkboxes in Laravel 4 controller (if checked)(如何獲取 Laravel 4 控制器中一系列復選框的值(如果選中))
本文介紹了如何獲取 Laravel 4 控制器中一系列復選框的值(如果選中)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想獲取我在 Laravel 4 表單中設置的一系列復選框的值.這是視圖中設置復選框的代碼:

I would like to get the values for a series of checkboxes I have set up in a Laravel 4 form. Here is the code in the view setting up the checkboxes:

@foreach ($friends as $friend)
<input tabindex="1" type="checkbox" name="friend[]" id="{{$friend}}" value="{{$friend}}">
@endforeach

在我的控制器中,我想獲取復選框的值并將它們放入一個數組中.我不完全確定如何做到這一點,但我認為它是這樣的:

In my controller, I would like to get the values for the checked boxes and put them in an array. I am not exactly sure how to do this, but I assume it is something like:

array[];

foreach($friend as $x)
if (isset(Input::get('friend')) {
        array[] = Input::get('friend');

 } 
endforeach

你能為我提供一個解決方案嗎?謝謝你.

Could you provide me with a solution to do this? Thank you.

這是我在控制器中的內容:

This is what I have in the controller:

public function describe_favorite() {

            $fan = Fan::find(Auth::user()->id);
            $fan->favorite_venue = Input::get('venue');
            $fan->favorite_experience = Input::get('experience');

            $friends_checked = Input::get('friend[]');

            print_r($friends_checked);

            if(is_array($friends_checked))
            {
             $fan->experience_friends = 5;
            }

            $fan->save();


            return Redirect::to('fans/home');

        }

它沒有通過if"循環.如何查看 print_r 的輸出以查看 $friends_checked 變量中的內容?

It is not going through the "if" loop. How do I see the output of the print_r to see what's in the $friends_checked variable?

推薦答案

如果復選框是相關的,那么你應該在 name 屬性中使用 [].

If checkboxes are related then you should use [] in the name attribute.

@foreach ($friends as $friend)
<input tabindex="1" type="checkbox" name="friend[]" id="{{$friend}}" value="{{$friend}}">
@endforeach


$friends_checked = Input::get('friend');
if(is_array($friends_checked))
{
   // do stuff with checked friends
}

這篇關于如何獲取 Laravel 4 控制器中一系列復選框的值(如果選中)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 激情婷婷 | 亚洲成人一区 | 特一级黄色毛片 | 天天操综合网站 | 韩日在线 | 亚洲丝袜天堂 | 中文字幕欧美日韩一区 | 久久国产精品免费视频 | 国产精品一区二区三区四区 | 亚洲一区二区三区四区av | 欧美日韩国产一区二区三区 | 国产视频综合 | 国产精品激情在线 | 色婷婷久久久久swag精品 | 亚洲精品久久久久avwww潮水 | 亚洲高清一区二区三区 | 天天综合网91 | 精品国产欧美一区二区 | 日韩在线免费视频 | 久久91av| 国产99久久 | 欧美性猛片aaaaaaa做受 | 国产免费一区二区三区最新6 | 激情91| 久久综合一区 | 日韩有码一区 | 国产偷自视频区视频 | av手机免费在线观看 | 欧美一a一片一级一片 | 在线午夜 | 天天天天操 | 国产日韩欧美另类 | 欧美jizzhd精品欧美巨大免费 | 精品久久久久久亚洲国产800 | 国产亚洲精品精品国产亚洲综合 | 伦理一区二区 | 亚洲欧美综合精品另类天天更新 | 久久骚| 中文字幕综合 | 久久久久国产精品 | 成人在线看片 |