Grav-plugin-admin: 条件付きフィールド-条件を他の/兄弟フィールドに設定します

作成日 2018年08月24日  ·  5コメント  ·  ソース: getgrav/grav-plugin-admin

テンプレートのブループリントファイルで、リピーター/リストフィールドを使用したいのですが、
オプション付きの選択フィールドがあり、
ユーザーが選択した選択肢を評価して、それに応じてフィールドを表示する条件付きフィールド。

ユーザーがさまざまなタイプのコンポーネントを追加/切り替えできる長い記事にこれを使用したいと思います

条件を選択フィールドの値に(繰り返し)設定するにはどうすればよいですか?
コードが表示されるようになったため、selectのみが表示され、条件は効果がありません。

        header.field.selection:
          type: list
          style: vertical
          label: Repeater/list with conditional field selection
          fields:
            .select: # this select sets the boolean for the conditional fields
              type: select
              size: long
              classes: fancy
              label: Select the type of field you would like to add
              options:
                tinymce: Textarea
                slideshow: Slideshow
                testimonial: Testimonial
                video: Video
            .tinymce:
              type: conditional # if Textarea was selected render the tinymce fields
              condition: "header.field.selection.select is same as('tinymce') ? 'true' : 'false'"
              fields: 
                .fieldName:
                  type: text
                  label: Tinymce
            .slideshow:
              type: conditional # if slideshow was selected render the slideshow fields
              condition: "header.field.selection.select is same as('slideshow') ? 'true' : 'false'"
              fields: 
                .fieldName2:
                  type: text
                  label: Slideshow
            .testimonial:
              type: conditional # if testimonial was selected render the testimonial fields
              condition: "header.field.selection.select is same as('testimonial') ? 'true' : 'false'"
              fields: 
                .fieldName3:
                  type: text
                  label: Testimonial
            .video:
              type: conditional # if video was selected render the video fields
              condition: "header.field.selection.select is same as('video') ? 'true' : 'false'"
              fields: 
                .fieldName4:
                  type: text
                  label: Video
question

全てのコメント5件

条件付きフィールドは、他のフィールドに基づいて「ライブ」で機能するものではありません。サービスを受けるときにPHP関数を実行し、決定を下すことができます。 それ以外の場合は、Javascriptを実行する必要があります。

rhuksterに感謝します。

私はなんとか「フレキシブルコンテンツフィールド」**(Wordpressの高度なカスタムフィールドのような)を作ることができました。 あなたはここでコードを見ることができ

**サブフィールド(レイアウト)のグループを定義し、それらを追加、編集、および並べ替えて、高度にカスタマイズされたコンテンツを作成します。

このようなものをFormプラグインのコアフィールドとして見たいと思います:)PRおそらく??

@rhukster
ブランチ 'feature / flexible-form-field'に対してプルリクエストが行われました。
スターテス:

  • フィールド選択テンプレートが使用可能です。 追加されたフィールドは正しく保存およびロードされています。
  • Js&Cssはまだ追加する必要があります。
  • example-fieldselection.yamlが追加されました。

私はいくつかの助けが必要です:

  • フィールドの並べ替えはfrontmatterに保存されていません。

tnx

(「genenenenaam」としてスラックチャネルにいます)

@rhukster

「リストアイテムの並べ替え」とフィールドテンプレートの名前「list.html.twig」に依存関係はありますか?

私はテストをしました、そしてそれは思われます:

  • 'list'フォルダが配置されているのと同じレベルに新しいフォルダ 'fieldselection'を作成した場合。
  • ファイル「list.html.twig」を複製し、名前を「fieldselection.html.twig」に変更して、「fieldselection」フォルダー内に配置します。
  • 'list'フィールドタイプを使用するブループリントを作成したが、それにタイプ 'fieldselection'を指定した場合。
    (これは違いを生むべきではないので、両方のタイプは同じコード内容を持っています)
  • 並べ替えは、タイプ 'fieldselection'では機能しませんが、タイプ 'list'では機能します。
    (アイテムの削除も同様)

これに対する答えは、新機能の現在の状態に関する私の問題を解決できると思います。

このページは役に立ちましたか?
0 / 5 - 0 評価