我正在使用v1。第4.14条WPAlchemy MetaBox PHP Class. 我在重复组中有2个选择菜单,available_from
和available_to
.
如果我在第一个选择菜单中选择星期一,在第二个选择星期三,然后保存帖子,第二个选择菜单的值将更改为第一个。所以都变成了星期一。但是,初始值在第一次保存时(星期一和星期三)会正确存储在DB中,但如果再次更新帖子,它们将更改为星期一和星期一。
任何一天的组合都会发生这种情况,但如果我在重复组之外使用下面的确切代码,它就会按预期工作。我希望有人以前遇到过这种情况,并且知道如何解决它。真的需要重复组。
<?php while($mb->have_fields_and_multi(\'availability\')): ?>
<?php $mb->the_group_open(); ?>
<label>Day (from)</label>
<?php $mb->the_field(\'available_from\'); ?>
<select name="<?php $mb->the_name(); ?>" id="<?php $mb->the_name(); ?>">
<option value="">Select Day</option>
<option value="Monday"<?php $mb->the_select_state(\'Monday\'); ?>>Monday</option>
<option value="Tuesday"<?php $mb->the_select_state(\'Tuesday\'); ?>>Tuesday</option>
<option value="Wednesday"<?php $mb->the_select_state(\'Wednesday\'); ?>>Wednesday</option>
<option value="Thursday"<?php $mb->the_select_state(\'Thursday\'); ?>>Thursday</option>
<option value="Friday"<?php $mb->the_select_state(\'Friday\'); ?>>Friday</option>
<option value="Saturday"<?php $mb->the_select_state(\'Saturday\'); ?>>Saturday</option>
<option value="Sunday"<?php $mb->the_select_state(\'Sunday\'); ?>>Sunday</option>
</select>
<label>Day (to)</label>
<?php $mb->the_field(\'available_to\'); ?>
<select name="<?php $mb->the_name(); ?>" id="<?php $mb->the_name(); ?>">
<option value="">Select Day</option>
<option value="Monday"<?php $mb->the_select_state(\'Monday\'); ?>>Monday</option>
<option value="Tuesday"<?php $mb->the_select_state(\'Tuesday\'); ?>>Tuesday</option>
<option value="Wednesday"<?php $mb->the_select_state(\'Wednesday\'); ?>>Wednesday</option>
<option value="Thursday"<?php $mb->the_select_state(\'Thursday\'); ?>>Thursday</option>
<option value="Friday"<?php $mb->the_select_state(\'Friday\'); ?>>Friday</option>
<option value="Saturday"<?php $mb->the_select_state(\'Saturday\'); ?>>Saturday</option>
<option value="Sunday"<?php $mb->the_select_state(\'Sunday\'); ?>>Sunday</option>
</select>
<div>
<a href="#" class="dodelete">Remove</a>
</div>
<?php $mb->the_group_close(); ?>
<?php endwhile; ?>
<a href="#" class="docopy-availability button">Add new day range</a>