app/Plugin/NZCustomPlugin/Resource/template/admin/form_edit.twig line 1

Open in your IDE?
  1. {% extends '@admin/default_frame.twig' %}
  2. {% block title %}フォーム編集{% endblock %}
  3. {% block sub_title %}{{ customForm.name|default('新規作成') }}{% endblock %}
  4. {% form_theme form '@admin/Form/bootstrap_4_horizontal_layout.html.twig' %}
  5. {% block stylesheet %}
  6. <style>
  7. /* フィールド管理テーブルのモダンスタイル */
  8. .field-management-table {
  9.     border-collapse: separate;
  10.     border-spacing: 0;
  11.     font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  12. }
  13. .field-management-table thead th {
  14.     background: #f7fafc !important;
  15.     color: #2d3748 !important;
  16.     font-weight: 600 !important;
  17.     font-size: 15px !important;
  18.     padding: 18px 16px !important;
  19.     border: none !important;
  20.     border-bottom: 2px solid #e2e8f0 !important;
  21.     text-align: left;
  22.     letter-spacing: 0.3px;
  23. }
  24. .field-management-table thead th:first-child {
  25.     border-radius: 10px 0 0 0;
  26. }
  27. .field-management-table thead th:last-child {
  28.     border-radius: 0 10px 0 0;
  29. }
  30. .field-management-table tbody tr {
  31.     transition: all 0.2s ease;
  32.     border-bottom: 1px solid #e2e8f0;
  33. }
  34. .field-management-table tbody tr:hover {
  35.     background-color: #f7fafc;
  36.     transform: translateX(2px);
  37. }
  38. .field-management-table tbody tr:last-child {
  39.     border-bottom: none;
  40. }
  41. .field-management-table tbody td {
  42.     padding: 16px 16px !important;
  43.     font-size: 15px !important;
  44.     color: #2d3748 !important;
  45.     vertical-align: middle;
  46. }
  47. .field-management-table code {
  48.     background: #edf2f7;
  49.     padding: 6px 10px;
  50.     border-radius: 6px;
  51.     font-size: 14px !important;
  52.     color: #667eea;
  53.     font-weight: 500;
  54. }
  55. .field-type-badge {
  56.     display: inline-block;
  57.     padding: 6px 14px;
  58.     border-radius: 20px;
  59.     font-size: 13px !important;
  60.     font-weight: 500;
  61.     background: #e6f4ff;
  62.     color: #1890ff;
  63. }
  64. .field-required-badge {
  65.     display: inline-block;
  66.     padding: 6px 14px;
  67.     border-radius: 20px;
  68.     font-size: 13px !important;
  69.     font-weight: 600;
  70.     background: #fff0f0;
  71.     color: #e53e3e;
  72. }
  73. .field-action-buttons {
  74.     display: flex;
  75.     gap: 6px;
  76.     align-items: center;
  77. }
  78. .field-action-btn {
  79.     display: inline-flex;
  80.     align-items: center;
  81.     justify-content: center;
  82.     width: 36px;
  83.     height: 36px;
  84.     border-radius: 8px;
  85.     border: 2px solid transparent;
  86.     transition: all 0.2s ease;
  87.     font-size: 14px;
  88.     cursor: pointer;
  89. }
  90. .field-action-btn.edit {
  91.     background: #667eea;
  92.     color: white;
  93. }
  94. .field-action-btn.edit:hover {
  95.     background: #5568d3;
  96.     transform: translateY(-2px);
  97.     box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  98. }
  99. .field-action-btn.delete {
  100.     background: #e53e3e;
  101.     color: white;
  102.     border: none;
  103. }
  104. .field-action-btn.delete:hover {
  105.     background: #c53030;
  106.     transform: translateY(-2px);
  107.     box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
  108. }
  109. .field-move-buttons {
  110.     display: flex;
  111.     flex-direction: column;
  112.     gap: 4px;
  113. }
  114. .field-move-btn {
  115.     width: 32px;
  116.     height: 32px;
  117.     display: flex;
  118.     align-items: center;
  119.     justify-content: center;
  120.     border: 2px solid #cbd5e0;
  121.     border-radius: 6px;
  122.     background: white;
  123.     color: #4a5568;
  124.     transition: all 0.2s ease;
  125.     cursor: pointer;
  126.     font-size: 12px;
  127. }
  128. .field-move-btn:hover {
  129.     background: #667eea;
  130.     border-color: #667eea;
  131.     color: white;
  132.     transform: scale(1.05);
  133. }
  134. .field-table-wrapper {
  135.     border-radius: 12px;
  136.     overflow: hidden;
  137.     box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  138. }
  139. .field-management-actions {
  140.     display: flex;
  141.     gap: 10px;
  142.     margin-bottom: 20px;
  143. }
  144. .field-management-actions .btn {
  145.     font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  146.     font-weight: 500;
  147.     padding: 10px 20px;
  148.     border-radius: 8px;
  149.     transition: all 0.2s ease;
  150. }
  151. .field-management-actions .btn:hover {
  152.     transform: translateY(-2px);
  153.     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  154. }
  155. </style>
  156. {% endblock %}
  157. {% block javascript %}
  158. <script>
  159. function toggleMailSettings() {
  160.     const sendCustomerMail = document.getElementById('form_send_customer_mail').checked;
  161.     const sendAdminMail = document.getElementById('form_send_admin_mail').checked;
  162.     
  163.     const mailSettingsRow = document.getElementById('mail-settings-row');
  164.     const adminMailRow = document.getElementById('admin-mail-row');
  165.     
  166.     // いずれかのメール送信が有効な場合、メール設定を表示
  167.     const showMailSettings = sendCustomerMail || sendAdminMail;
  168.     if (mailSettingsRow) {
  169.         mailSettingsRow.style.display = showMailSettings ? '' : 'none';
  170.     }
  171.     
  172.     // 管理者メール送信が有効な場合、管理者メールアドレスを表示
  173.     if (adminMailRow) {
  174.         adminMailRow.style.display = sendAdminMail ? '' : 'none';
  175.     }
  176. }
  177. document.addEventListener('DOMContentLoaded', function() {
  178.     const sendCustomerMail = document.getElementById('form_send_customer_mail');
  179.     const sendAdminMail = document.getElementById('form_send_admin_mail');
  180.     
  181.     if (sendCustomerMail) {
  182.         sendCustomerMail.addEventListener('change', toggleMailSettings);
  183.     }
  184.     if (sendAdminMail) {
  185.         sendAdminMail.addEventListener('change', toggleMailSettings);
  186.     }
  187.     
  188.     toggleMailSettings();
  189. });
  190. </script>
  191. {% endblock %}
  192. {% block main %}
  193. <div class="c-contentsArea__cols">
  194.     <div class="c-contentsArea__primaryCol">
  195.         <div class="c-primaryCol">
  196.             <form method="post">
  197.                 {{ form_widget(form._token) }}
  198.                 
  199.                 <div class="card rounded border-0 mb-4">
  200.                     <div class="card-header">基本設定</div>
  201.                     <div class="card-body">
  202.                         {{ form_row(form.name) }}
  203.                         {{ form_row(form.form_key) }}
  204.                         {{ form_row(form.description) }}
  205.                         {{ form_row(form.is_active) }}
  206.                     </div>
  207.                 </div>
  208.                 <div class="card rounded border-0 mb-4">
  209.                     <div class="card-header">
  210.                         <i class="fa fa-desktop mr-2"></i>レイアウト設定
  211.                     </div>
  212.                     <div class="card-body">
  213.                         {{ form_row(form.Layout) }}
  214.                         {{ form_row(form.LayoutMobile) }}
  215.                         
  216.                         <div class="alert alert-info">
  217.                             <i class="fa fa-info-circle mr-2"></i>
  218.                             <strong>レイアウトについて</strong>
  219.                             <ul class="mb-0 mt-2">
  220.                                 <li>「コンテンツ > レイアウト管理」で作成したレイアウトを選択できます</li>
  221.                                 <li>未選択の場合は、デフォルトレイアウトが適用されます</li>
  222.                                 <li>LP風の完全独立ページを作成する場合は、ヘッダー・フッターなしのレイアウトを作成してください</li>
  223.                             </ul>
  224.                         </div>
  225.                     </div>
  226.                 </div>
  227.                 <div class="card rounded border-0 mb-4">
  228.                     <div class="card-header">公開設定</div>
  229.                     <div class="card-body">
  230.                         {{ form_row(form.publish_start_date) }}
  231.                         {{ form_row(form.publish_end_date) }}
  232.                         {{ form_row(form.require_login) }}
  233.                     </div>
  234.                 </div>
  235.                 <div class="card rounded border-0 mb-4">
  236.                     <div class="card-header">メール設定</div>
  237.                     <div class="card-body">
  238.                         {{ form_row(form.send_customer_mail) }}
  239.                         {{ form_row(form.send_admin_mail) }}
  240.                         
  241.                         <div id="admin-mail-row">
  242.                             {{ form_row(form.admin_mail_address) }}
  243.                         </div>
  244.                         
  245.                         <div id="mail-settings-row">
  246.                             {{ form_row(form.mail_subject) }}
  247.                             {{ form_row(form.mail_template) }}
  248.                             
  249.                             <div class="alert alert-info">
  250.                                 <h5>利用可能な変数</h5>
  251.                                 <ul class="mb-0">
  252.                                     <li><code>{form_name}</code> - フォーム名</li>
  253.                                     <li><code>{submit_date}</code> - 送信日時</li>
  254.                                     <li><code>{フィールド名}</code> - 各フィールドの値(例: {email}, {name})</li>
  255.                                 </ul>
  256.                             </div>
  257.                         </div>
  258.                     </div>
  259.                 </div>
  260.                 <div class="card rounded border-0 mb-4">
  261.                     <div class="card-header">送信完了画面設定</div>
  262.                     <div class="card-body">
  263.                         {{ form_row(form.complete_message) }}
  264.                         
  265.                         <div class="alert alert-info">
  266.                             <i class="fa fa-info-circle mr-2"></i>
  267.                             未設定の場合は、デフォルトメッセージ「お問い合わせありがとうございました。内容を確認の上、担当者よりご連絡させていただきます。」が表示されます。
  268.                         </div>
  269.                     </div>
  270.                 </div>
  271.                 <div class="c-conversionArea">
  272.                     <div class="c-conversionArea__container">
  273.                         <div class="row justify-content-between align-items-center">
  274.                             <div class="col-6">
  275.                                 <div class="c-conversionArea__leftBlockItem">
  276.                                     <a class="c-baseLink" href="{{ url('nzcustomplugin_admin_list') }}">
  277.                                         <i class="fa fa-backward" aria-hidden="true"></i>
  278.                                         <span>フォーム一覧に戻る</span>
  279.                                     </a>
  280.                                 </div>
  281.                             </div>
  282.                             <div class="col-6">
  283.                                 <div class="row align-items-center justify-content-end">
  284.                                     <div class="col-auto">
  285.                                         <button class="btn btn-ec-conversion px-5" type="submit">
  286.                                             保存
  287.                                         </button>
  288.                                     </div>
  289.                                 </div>
  290.                             </div>
  291.                         </div>
  292.                     </div>
  293.                 </div>
  294.             </form>
  295.             {% if customForm.id %}
  296.             <div class="card rounded border-0 mb-4 mt-5">
  297.                 <div class="card-header">フィールド管理</div>
  298.                 <div class="card-body">
  299.                     <div class="field-management-actions">
  300.                         <a href="{{ url('nzcustomplugin_admin_field_new', {'form_id': customForm.id}) }}" class="btn btn-ec-regular">
  301.                             <i class="fa fa-plus-circle mr-1"></i>
  302.                             フィールドを追加
  303.                         </a>
  304.                         <a href="{{ url('nzcustomplugin_admin_preview', {'id': customForm.id}) }}" class="btn btn-ec-regular" target="_blank">
  305.                             <i class="fa fa-external-link mr-1"></i>
  306.                             プレビュー
  307.                         </a>
  308.                         <a href="{{ url('nzcustomplugin_admin_submissions', {'form_id': customForm.id}) }}" class="btn btn-ec-regular">
  309.                             <i class="fa fa-database mr-1"></i>
  310.                             送信データ一覧
  311.                         </a>
  312.                     </div>
  313.                     {% if customForm.formFields|length > 0 %}
  314.                     <div class="field-table-wrapper">
  315.                         <table class="table table-sm mb-0 field-management-table">
  316.                             <thead>
  317.                                 <tr>
  318.                                     <th style="width: 50px;">順序</th>
  319.                                     <th>ラベル</th>
  320.                                     <th>フィールド名</th>
  321.                                     <th>タイプ</th>
  322.                                     <th>必須</th>
  323.                                     <th style="width: 120px;">操作</th>
  324.                                 </tr>
  325.                             </thead>
  326.                             <tbody>
  327.                                 {% for field in customForm.formFields %}
  328.                                 <tr>
  329.                                     <td>
  330.                                         <div class="field-move-buttons">
  331.                                             {% if not loop.first %}
  332.                                             <a href="{{ url('nzcustomplugin_admin_field_move_up', {'id': field.id}) }}" class="field-move-btn">
  333.                                                 <i class="fa fa-arrow-up"></i>
  334.                                             </a>
  335.                                             {% endif %}
  336.                                             {% if not loop.last %}
  337.                                             <a href="{{ url('nzcustomplugin_admin_field_move_down', {'id': field.id}) }}" class="field-move-btn">
  338.                                                 <i class="fa fa-arrow-down"></i>
  339.                                             </a>
  340.                                             {% endif %}
  341.                                         </div>
  342.                                     </td>
  343.                                     <td><strong>{{ field.label }}</strong></td>
  344.                                     <td><code>{{ field.fieldName }}</code></td>
  345.                                     <td>
  346.                                         {% set typeLabels = {
  347.                                             'text': 'テキスト',
  348.                                             'textarea': 'テキストエリア',
  349.                                             'email': 'メール',
  350.                                             'tel': '電話番号',
  351.                                             'number': '数値',
  352.                                             'date': '日付',
  353.                                             'radio': 'ラジオボタン',
  354.                                             'checkbox': 'チェックボックス',
  355.                                             'select': 'セレクト',
  356.                                             'select_multiple': '複数選択',
  357.                                             'file': 'ファイル'
  358.                                         } %}
  359.                                         <span class="field-type-badge">{{ typeLabels[field.fieldType]|default(field.fieldType) }}</span>
  360.                                     </td>
  361.                                     <td>
  362.                                         {% if field.required %}
  363.                                             <span class="field-required-badge">必須</span>
  364.                                         {% endif %}
  365.                                     </td>
  366.                                     <td>
  367.                                         <div class="field-action-buttons">
  368.                                             <a href="{{ url('nzcustomplugin_admin_field_edit', {'form_id': customForm.id, 'field_id': field.id}) }}" class="field-action-btn edit" title="編集">
  369.                                                 <i class="fa fa-edit"></i>
  370.                                             </a>
  371.                                             <form action="{{ url('nzcustomplugin_admin_field_delete', {'form_id': customForm.id, 'field_id': field.id}) }}" method="post" style="display: inline; margin: 0;" onsubmit="return confirm('このフィールドを削除してもよろしいですか?');">
  372.                                                 <input type="hidden" name="_token" value="{{ csrf_token('delete' ~ field.id) }}">
  373.                                                 <button type="submit" class="field-action-btn delete" title="削除">
  374.                                                     <i class="fa fa-trash"></i>
  375.                                                 </button>
  376.                                             </form>
  377.                                         </div>
  378.                                     </td>
  379.                                 </tr>
  380.                                 {% endfor %}
  381.                             </tbody>
  382.                         </table>
  383.                     </div>
  384.                     {% else %}
  385.                     <div class="alert alert-warning">
  386.                         <i class="fa fa-exclamation-triangle mr-2"></i>
  387.                         まだフィールドが追加されていません。「フィールドを追加」ボタンからフィールドを作成してください。
  388.                     </div>
  389.                     {% endif %}
  390.                 </div>
  391.             </div>
  392.             {% endif %}
  393.         </div>
  394.     </div>
  395. </div>
  396. {% endblock %}