久久久久久久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)
主站蜘蛛池模板: 欧美精品一二三区 | 拍真实国产伦偷精品 | 亚洲成人精品一区二区 | 日日干夜夜操天天操 | 麻豆久久久久久久久久 | 亚洲人成在线观看 | 中文字幕在线国产 | 成人免费视频 | 2一3sex性hd| 日韩亚洲视频 | 国产成人自拍一区 | 久久久久国产精品一区三寸 | 五月免费视频 | 久久婷婷色| 国产一级片91| 免费的日批视频 | 久草青青草 | 成人av网站在线观看 | 在线免费观看成人 | 九九热精品视频在线观看 | 国产乱码精品1区2区3区 | 亚洲欧美日韩一区 | 超碰人人爱| 精品欧美一区二区在线观看 | 亚洲一区二区高清 | 欧美精品电影一区 | 国产日韩欧美一区二区 | 久久视频精品 | 亚洲成网 | 国产7777 | 久久久久久av | 亚洲国产午夜 | 久久久久久91 | 欧美成人一级 | 在线看av的网址 | 国产精品视频一二三区 | 一区二区三区精品视频 | 亚洲精品乱码久久久久久久久久 | 日韩久久中文字幕 | h视频在线播放 | 午夜视频免费 |