<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 關系行為 ## 關系行為 ### [](https://octobercms.com/docs/backend/relations#introduction)介紹 **關系行為**是控制器修改器,用于輕松管理頁面上的復雜[模型](https://octobercms.com/docs/database/model)關系。不要與僅提供簡單管理的[列表關系列](https://octobercms.com/docs/backend/lists#column-types)或[表單關系字段](https://octobercms.com/docs/backend/forms#widget-relation)混淆。 關系行為取決于[關系定義](https://octobercms.com/docs/backend/relations#relation-definitions)。為了使用關系行為,您應該將`Backend.Behaviors.RelationController`定義添加到`$implement`控制器類的字段中。另外,`$relationConfig`應該定義class屬性,并且其值應引用用于[配置行為選項](https://octobercms.com/docs/backend/relations#configuring-relation)的YAML文件。 ~~~ namespace Acme\Projects\Controllers; class Projects extends Controller { public $implement = [ 'Backend.Behaviors.FormController', 'Backend.Behaviors.RelationController', ]; public $formConfig = 'config_form.yaml'; public $relationConfig = 'config_relation.yaml'; } ~~~ > **注意:**關系行為經常與[表單行為](https://octobercms.com/docs/backend/form)一起使用。 ### [](https://octobercms.com/docs/backend/relations#configuring-relation)配置關系行為 `$relationConfig`屬性中引用的配置文件以YAML格式定義。該文件應放置在控制器的[views目錄中](https://octobercms.com/docs/backend/controllers-ajax/#introduction)。所需的配置取決于目標模型和相關模型之間的[關系類型](https://octobercms.com/docs/backend/relations#relationship-types)。 關系配置文件中的第一級字段定義目標模型中的關系名稱。例如: ~~~ class Invoice { public $hasMany = [ 'items' => ['Acme\Pay\Models\InvoiceItem'], ]; } ~~~ 具有關聯關系的*Invoice*模型`items`應使用相同的關聯名稱定義第一級字段: ~~~ # =================================== # Relation Behavior Config # =================================== items: label: Invoice Line Item view: list: $/acme/pay/models/invoiceitem/columns.yaml toolbarButtons: create|delete manage: form: $/acme/pay/models/invoiceitem/fields.yaml recordsPerPage: 10 ~~~ 然后,以下選項用于每個關系名稱定義: | 選項 | 描述 | | --- | --- | | **label** | 該關系的標簽,以單數形式表示。 | | **view** | 特定于視圖容器的配置,請參見下文。 | | **manage** | 特定于管理彈出窗口的配置,請參見下文。 | | **pivot** | 表單字段定義文件的引用,用于[與數據透視表數據建立關系](https://octobercms.com/docs/backend/relations#belongs-to-many-pivot)。 | | **emptyMessage** | 關系為空時顯示的消息,可選。 | | **readOnly** | 禁用添加,更新,刪除或創建關系的功能。默認值:false | | **deferredBinding** | [](https://octobercms.com/docs/database/model#deferred-binding)可用[會話密鑰延遲所有綁定操作](https://octobercms.com/docs/database/model#deferred-binding)。默認值:false | 可以為**view**或**manage**選項指定這些配置值,適用于列表,表單或兩者的呈現類型。 | 選項 | 類型 | 描述 | | --- | --- | --- | | **form** | Form | 表單域定義文件的參考,請參閱[后端表單域](https://octobercms.com/docs/backend/forms#form-fields)。 | | **list** | List | 對列表列定義文件的引用,請參閱[后端列表列](https://octobercms.com/docs/backend/lists#list-columns)。 | | **showSearch** | List | 顯示用于搜索記錄的輸入。默認值:false | | **showSorting** | List | 在每一列上顯示排序鏈接。默認值:true | | **defaultSort** | List | 未定義用戶首選項時,設置默認的排序列和方向。支持帶鍵`column`和的字符串或數組`direction`。 | | **recordsPerPage** | List | 每頁顯示的最大行數。 | | **noRecordsMessage** | List | 找不到記錄時顯示的消息,可以引用[本地化字符串](https://octobercms.com/docs/plugin/localization)。 | | **conditions** | List | 指定要應用于列表模型查詢的原始where查詢語句。 | | **scope** | List | 指定在**相關表單模型中**定義的[查詢范圍方法](https://octobercms.com/docs/database/model#query-scopes),以始終應用于列表查詢。該關系將附加到的**模型**(即**父模型**)作為第二個參數(是第一個)傳遞給此范圍方法。`$query` | | **filter** | List | 對過濾器作用域定義文件的引用,請參閱[后端列表過濾器](https://octobercms.com/docs/backend/lists#list-filters)。 | 只能為**視圖**選項指定這些配置值。 | 選項 | 類型 | 描述 | | --- | --- | --- | | **showCheckboxes** | 清單 | 在每個記錄旁邊顯示復選框。 | | **recordUrl** | 清單 | 將每個列表記錄鏈接到另一個頁面。例如:**users / update /:id**。該`:id`部分將替換為記錄標識符。 | | **customViewPath** | 清單 | 指定一個自定義視圖路徑以覆蓋列表使用的部分。 | | **recordOnClick** | 清單 | 單擊記錄時執行的自定義JavaScript代碼。 | | **toolbarPartial** | 都 | 使用工具欄按鈕對控制器部分文件的引用。例如:**\_relation\_toolbar.htm**。此選項將覆蓋工具*欄按鈕*選項。 | | **toolbarButtons** | 都 | 要顯示的按鈕集。可以將其格式化為數組或管道分隔的字符串,或設置為`false`不顯示任何按鈕。可用的選項有:`create`,`update`,`delete`,`add`,`remove`,`link`,和`unlink`。范例:`add\|remove`。 另外,您可以通過將此屬性設置為關聯數組來自定義這些按鈕內的文本,其中鍵為按鈕類型,值為該按鈕的文本。范例:`create: 'Assign User'`。該值還支持翻譯。 | 只能為**manage**選項指定這些配置值。 | 選項 | 類型 | 描述 | | --- | --- | --- | | **title** | 都 | 彈出標題,可以引用[本地化字符串](https://octobercms.com/docs/plugin/localization)。 此外,可以通過將每個模式的標題設置為關聯數組來分別自定義每種模式的標題,其中鍵為模式,值為顯示該模式時使用的標題。例如:`form: acme.blog::lang.subcategory.FormTitle`。 | | **context** | 形成 | 顯示表單的上下文。可以是字符串或帶有鍵的數組:創建,更新。 | ### [](https://octobercms.com/docs/backend/relations#relation-display)顯示關系經理 在可以在任何頁面上管理關系之前,必須首先通過調用`initRelation`方法在控制器中初始化目標模型。 ~~~ $post = Post::where('id', 7)->first(); $this->initRelation($post); ~~~ > **注:**該[表單行為](https://octobercms.com/docs/backend/forms)在其創建,更新和預覽操作將自動初始化模型。 然后可以通過調用該`relationRender`方法為指定的關系定義顯示關系管理器。例如,如果要在“[預覽”](https://octobercms.com/docs/backend/forms#form-preview-view)頁面上顯示關系管理器,**preview.htm**視圖的內容可能如下所示: ~~~ <?= $this->formRenderPreview() ?> <?= $this->relationRender('comments') ?> ~~~ 您可以通過將選項作為第二個參數傳遞來指示關系管理器以只讀模式呈現: ~~~ <?= $this->relationRender('comments', ['readOnly' => true]) ?> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看