我有两个表,它们是相关的strategies和strategy_conditions策略可以有许多strategy_conditions。
我已经用一些javascript更新了策略add.php,我可以将strategy_conditions添加到页面、<input type="text" name="strategies_conditions[0][name]" value="">、<input type="text" name="strategies_conditions[1][name]" value="">等。
我希望现在能够在策略edit.php上同时编辑strategies_conditions,我可以循环并添加strategies_conditions输入,但我的问题是输入的名称格式错误,无法保存。输入应该是<input type="text" name="strategies_conditions[0][name]" value="">,但它却是<input type="text" name="name" value="">
下面是cakephp代码
<div class="strategies form content">
<?= $this->Form->create($strategy) ?>
<fieldset>
<legend><?= __('Edit Strategy') ?></legend>
<?php
echo $this->Form->control('user_id', ['options' => $users]);
echo $this->Form->control('name');
echo $this->Form->control('description');
echo $this->Form->control('one_hundred_trades');
?>
<table id="conditions-table">
<thead>
<tr>
<th>Name</th>
<th>Level</th>
<th></th>
</tr>
<tr>
<td>
<input id="condtitions-input"></input>
<select id="condtitions-level">
<option value="Mandatory">Mandatory</option>
<option value="Important">Important</option>
<option value="Support">Support</option>
</select>
</td>
<td>
<button id="add-condtition" type='button' onclick="addCondition()">Add Conditions</button></td>
</td>
</tr>
<?php foreach ($strategy->strategies_conditions as $strategiesConditions) : ?>
<tr>
<td><?php echo $this->Form->control('name', array( 'label' => false )); ?></td>
</tr>
<?php endforeach; ?>
</thead>
</table>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>发布于 2020-08-04 20:47:59
<div class="strategies form content">
<?= $this->Form->create($strategy) ?>
<fieldset>
<legend><?= __('Edit Strategy') ?></legend>
<?php
echo $this->Form->control('user_id', ['options' => $users]);
echo $this->Form->control('name');
echo $this->Form->control('description');
echo $this->Form->control('one_hundred_trades');
?>
<table id="conditions-table">
<thead>
<tr>
<th>Name</th>
<th>Level</th>
<th></th>
</tr>
<tr>
<td>
<input id="condtitions-input"></input>
<select id="condtitions-level">
<option value="Mandatory">Mandatory</option>
<option value="Important">Important</option>
<option value="Support">Support</option>
</select>
</td>
<td>
<button id="add-condtition" type='button' onclick="addCondition()">Add Conditions</button></td>
</td>
</tr>
<?php foreach ($strategy->strategies_conditions as $key => $strategiesConditions) : ?>
<tr>
<td><?php echo $this->Form->control('strategies_conditions.'.$key.'.name', array( 'label' => false )); ?></td>
</tr>
<?php endforeach; ?>
</thead>
</table>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>https://stackoverflow.com/questions/63238802
复制相似问题