當前位置: 首頁>>代碼示例>>PHP>>正文


PHP View::nest方法代碼示例

本文整理匯總了PHP中Illuminate\Contracts\View\View::nest方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::nest方法的具體用法?PHP View::nest怎麽用?PHP View::nest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Contracts\View\View的用法示例。


在下文中一共展示了View::nest方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: compose

 /**
  * Bind data to the view.
  *
  * @param  View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     if ($view->group_form_errors and $view->errors->any()) {
         $view->nest('form_error_content', $view->bsb_pkg_ref . '::form.control.errors', ['errors' => $view->errors->all()]);
     }
     foreach ($view->groups as $name => &$input) {
         if (is_array($input)) {
             if (count(array_filter(array_keys($input), 'is_string'))) {
                 //The array contains named keys, generate inputs from these options
                 $view_name = $view->bsb_pkg_ref . '::input.' . (empty($input['type']) ? 'text' : $input['type']);
                 if (!view()->exists($view_name)) {
                     $view_name = $view->bsb_pkg_ref . '::input.' . 'text';
                 }
                 $input = view($view_name, array_merge(compact('name'), $input), $view->getData());
             } else {
                 //The array contains html strings, display them together within a form-group
                 $input = view($view->bsb_pkg_ref . '::input.group', ['content' => implode("\n", $input)], $view->getData());
             }
         } elseif (!str_contains($input, '.form-group')) {
             //The input is just a string of html, but it doesn't contain any .form-group element, so we'll wrap it in one
             $input = view($view->bsb_pkg_ref . '::input.group', ['content' => $input], $view->getData());
         }
     }
     //TODO: add form-horizontal and form-inline options
 }
開發者ID:fewagency,項目名稱:twbs-blade,代碼行數:32,代碼來源:FormComposer.php

示例2: compose

 /**
  * Bind data to the view.
  *
  * @param  View $view
  *
  * @throws \Exception
  */
 public function compose(View $view)
 {
     if (empty($view->name) and !str_contains($view->getName(), ['csrf', 'group'])) {
         //TODO: check if these exceptions can actually be caught. Perhaps it needs to log to file instead?
         throw new \Exception('Input needs a "name" parameter set in ' . $view->getPath());
     }
     $data['control_id'] = $view->bsb_pkg_ref . $view->form_id . $view->name;
     //TODO: handle unique id if name is repeated within the form with [] array syntax and radios/checkboxes
     if (!empty($view->name) and $view->errors->has($view->name)) {
         $data['has_error'] = true;
         if (!$view->group_form_errors) {
             $view->nest('control_error_content', $view->bsb_pkg_ref . '::form.control.errors', ['errors' => $view->errors->get($view->name)]);
         }
     }
     if ($view->control_error_content or $view->help_text or $view->html_help_text) {
         $data['control_description_id'] = $data['control_id'] . 'desc';
     }
     $view->with($data);
 }
開發者ID:fewagency,項目名稱:twbs-blade,代碼行數:26,代碼來源:InputComposer.php


注:本文中的Illuminate\Contracts\View\View::nest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。