{% extends '@admin/default_frame.twig' %}
{% block title %}フォーム編集{% endblock %}
{% block sub_title %}{{ customForm.name|default('新規作成') }}{% endblock %}
{% form_theme form '@admin/Form/bootstrap_4_horizontal_layout.html.twig' %}
{% block stylesheet %}
<style>
/* フィールド管理テーブルのモダンスタイル */
.field-management-table {
border-collapse: separate;
border-spacing: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.field-management-table thead th {
background: #f7fafc !important;
color: #2d3748 !important;
font-weight: 600 !important;
font-size: 15px !important;
padding: 18px 16px !important;
border: none !important;
border-bottom: 2px solid #e2e8f0 !important;
text-align: left;
letter-spacing: 0.3px;
}
.field-management-table thead th:first-child {
border-radius: 10px 0 0 0;
}
.field-management-table thead th:last-child {
border-radius: 0 10px 0 0;
}
.field-management-table tbody tr {
transition: all 0.2s ease;
border-bottom: 1px solid #e2e8f0;
}
.field-management-table tbody tr:hover {
background-color: #f7fafc;
transform: translateX(2px);
}
.field-management-table tbody tr:last-child {
border-bottom: none;
}
.field-management-table tbody td {
padding: 16px 16px !important;
font-size: 15px !important;
color: #2d3748 !important;
vertical-align: middle;
}
.field-management-table code {
background: #edf2f7;
padding: 6px 10px;
border-radius: 6px;
font-size: 14px !important;
color: #667eea;
font-weight: 500;
}
.field-type-badge {
display: inline-block;
padding: 6px 14px;
border-radius: 20px;
font-size: 13px !important;
font-weight: 500;
background: #e6f4ff;
color: #1890ff;
}
.field-required-badge {
display: inline-block;
padding: 6px 14px;
border-radius: 20px;
font-size: 13px !important;
font-weight: 600;
background: #fff0f0;
color: #e53e3e;
}
.field-action-buttons {
display: flex;
gap: 6px;
align-items: center;
}
.field-action-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
border-radius: 8px;
border: 2px solid transparent;
transition: all 0.2s ease;
font-size: 14px;
cursor: pointer;
}
.field-action-btn.edit {
background: #667eea;
color: white;
}
.field-action-btn.edit:hover {
background: #5568d3;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.field-action-btn.delete {
background: #e53e3e;
color: white;
border: none;
}
.field-action-btn.delete:hover {
background: #c53030;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}
.field-move-buttons {
display: flex;
flex-direction: column;
gap: 4px;
}
.field-move-btn {
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid #cbd5e0;
border-radius: 6px;
background: white;
color: #4a5568;
transition: all 0.2s ease;
cursor: pointer;
font-size: 12px;
}
.field-move-btn:hover {
background: #667eea;
border-color: #667eea;
color: white;
transform: scale(1.05);
}
.field-table-wrapper {
border-radius: 12px;
overflow: hidden;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
.field-management-actions {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.field-management-actions .btn {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
font-weight: 500;
padding: 10px 20px;
border-radius: 8px;
transition: all 0.2s ease;
}
.field-management-actions .btn:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
</style>
{% endblock %}
{% block javascript %}
<script>
function toggleMailSettings() {
const sendCustomerMail = document.getElementById('form_send_customer_mail').checked;
const sendAdminMail = document.getElementById('form_send_admin_mail').checked;
const mailSettingsRow = document.getElementById('mail-settings-row');
const adminMailRow = document.getElementById('admin-mail-row');
// いずれかのメール送信が有効な場合、メール設定を表示
const showMailSettings = sendCustomerMail || sendAdminMail;
if (mailSettingsRow) {
mailSettingsRow.style.display = showMailSettings ? '' : 'none';
}
// 管理者メール送信が有効な場合、管理者メールアドレスを表示
if (adminMailRow) {
adminMailRow.style.display = sendAdminMail ? '' : 'none';
}
}
document.addEventListener('DOMContentLoaded', function() {
const sendCustomerMail = document.getElementById('form_send_customer_mail');
const sendAdminMail = document.getElementById('form_send_admin_mail');
if (sendCustomerMail) {
sendCustomerMail.addEventListener('change', toggleMailSettings);
}
if (sendAdminMail) {
sendAdminMail.addEventListener('change', toggleMailSettings);
}
toggleMailSettings();
});
</script>
{% endblock %}
{% block main %}
<div class="c-contentsArea__cols">
<div class="c-contentsArea__primaryCol">
<div class="c-primaryCol">
<form method="post">
{{ form_widget(form._token) }}
<div class="card rounded border-0 mb-4">
<div class="card-header">基本設定</div>
<div class="card-body">
{{ form_row(form.name) }}
{{ form_row(form.form_key) }}
{{ form_row(form.description) }}
{{ form_row(form.is_active) }}
</div>
</div>
<div class="card rounded border-0 mb-4">
<div class="card-header">
<i class="fa fa-desktop mr-2"></i>レイアウト設定
</div>
<div class="card-body">
{{ form_row(form.Layout) }}
{{ form_row(form.LayoutMobile) }}
<div class="alert alert-info">
<i class="fa fa-info-circle mr-2"></i>
<strong>レイアウトについて</strong>
<ul class="mb-0 mt-2">
<li>「コンテンツ > レイアウト管理」で作成したレイアウトを選択できます</li>
<li>未選択の場合は、デフォルトレイアウトが適用されます</li>
<li>LP風の完全独立ページを作成する場合は、ヘッダー・フッターなしのレイアウトを作成してください</li>
</ul>
</div>
</div>
</div>
<div class="card rounded border-0 mb-4">
<div class="card-header">公開設定</div>
<div class="card-body">
{{ form_row(form.publish_start_date) }}
{{ form_row(form.publish_end_date) }}
{{ form_row(form.require_login) }}
</div>
</div>
<div class="card rounded border-0 mb-4">
<div class="card-header">メール設定</div>
<div class="card-body">
{{ form_row(form.send_customer_mail) }}
{{ form_row(form.send_admin_mail) }}
<div id="admin-mail-row">
{{ form_row(form.admin_mail_address) }}
</div>
<div id="mail-settings-row">
{{ form_row(form.mail_subject) }}
{{ form_row(form.mail_template) }}
<div class="alert alert-info">
<h5>利用可能な変数</h5>
<ul class="mb-0">
<li><code>{form_name}</code> - フォーム名</li>
<li><code>{submit_date}</code> - 送信日時</li>
<li><code>{フィールド名}</code> - 各フィールドの値(例: {email}, {name})</li>
</ul>
</div>
</div>
</div>
</div>
<div class="card rounded border-0 mb-4">
<div class="card-header">送信完了画面設定</div>
<div class="card-body">
{{ form_row(form.complete_message) }}
<div class="alert alert-info">
<i class="fa fa-info-circle mr-2"></i>
未設定の場合は、デフォルトメッセージ「お問い合わせありがとうございました。内容を確認の上、担当者よりご連絡させていただきます。」が表示されます。
</div>
</div>
</div>
<div class="c-conversionArea">
<div class="c-conversionArea__container">
<div class="row justify-content-between align-items-center">
<div class="col-6">
<div class="c-conversionArea__leftBlockItem">
<a class="c-baseLink" href="{{ url('nzcustomplugin_admin_list') }}">
<i class="fa fa-backward" aria-hidden="true"></i>
<span>フォーム一覧に戻る</span>
</a>
</div>
</div>
<div class="col-6">
<div class="row align-items-center justify-content-end">
<div class="col-auto">
<button class="btn btn-ec-conversion px-5" type="submit">
保存
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
{% if customForm.id %}
<div class="card rounded border-0 mb-4 mt-5">
<div class="card-header">フィールド管理</div>
<div class="card-body">
<div class="field-management-actions">
<a href="{{ url('nzcustomplugin_admin_field_new', {'form_id': customForm.id}) }}" class="btn btn-ec-regular">
<i class="fa fa-plus-circle mr-1"></i>
フィールドを追加
</a>
<a href="{{ url('nzcustomplugin_admin_preview', {'id': customForm.id}) }}" class="btn btn-ec-regular" target="_blank">
<i class="fa fa-external-link mr-1"></i>
プレビュー
</a>
<a href="{{ url('nzcustomplugin_admin_submissions', {'form_id': customForm.id}) }}" class="btn btn-ec-regular">
<i class="fa fa-database mr-1"></i>
送信データ一覧
</a>
</div>
{% if customForm.formFields|length > 0 %}
<div class="field-table-wrapper">
<table class="table table-sm mb-0 field-management-table">
<thead>
<tr>
<th style="width: 50px;">順序</th>
<th>ラベル</th>
<th>フィールド名</th>
<th>タイプ</th>
<th>必須</th>
<th style="width: 120px;">操作</th>
</tr>
</thead>
<tbody>
{% for field in customForm.formFields %}
<tr>
<td>
<div class="field-move-buttons">
{% if not loop.first %}
<a href="{{ url('nzcustomplugin_admin_field_move_up', {'id': field.id}) }}" class="field-move-btn">
<i class="fa fa-arrow-up"></i>
</a>
{% endif %}
{% if not loop.last %}
<a href="{{ url('nzcustomplugin_admin_field_move_down', {'id': field.id}) }}" class="field-move-btn">
<i class="fa fa-arrow-down"></i>
</a>
{% endif %}
</div>
</td>
<td><strong>{{ field.label }}</strong></td>
<td><code>{{ field.fieldName }}</code></td>
<td>
{% set typeLabels = {
'text': 'テキスト',
'textarea': 'テキストエリア',
'email': 'メール',
'tel': '電話番号',
'number': '数値',
'date': '日付',
'radio': 'ラジオボタン',
'checkbox': 'チェックボックス',
'select': 'セレクト',
'select_multiple': '複数選択',
'file': 'ファイル'
} %}
<span class="field-type-badge">{{ typeLabels[field.fieldType]|default(field.fieldType) }}</span>
</td>
<td>
{% if field.required %}
<span class="field-required-badge">必須</span>
{% endif %}
</td>
<td>
<div class="field-action-buttons">
<a href="{{ url('nzcustomplugin_admin_field_edit', {'form_id': customForm.id, 'field_id': field.id}) }}" class="field-action-btn edit" title="編集">
<i class="fa fa-edit"></i>
</a>
<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('このフィールドを削除してもよろしいですか?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ field.id) }}">
<button type="submit" class="field-action-btn delete" title="削除">
<i class="fa fa-trash"></i>
</button>
</form>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-warning">
<i class="fa fa-exclamation-triangle mr-2"></i>
まだフィールドが追加されていません。「フィールドを追加」ボタンからフィールドを作成してください。
</div>
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}