It looks like you're new here. If you want to get involved, click one of these buttons!
function index()
{
$this->load->library('form_builder');
$this->form_builder->load_custom_fields(APPPATH.'config/custom_fields.php');
if (!empty($_POST))
{
// put your processing code here...
}
$fields = array();
$fields['first_name'] = array('required' => false);
$fields['last_name'] = array('required' => false);
$fields['email'] = array('required' => false);
$fields['state'] = array('type' => 'state');
$fields['template_phone'] = array(
'display_label' => false,
'add_extra' => false,
'init_display' => 'first',
'dblclick' => 'toggle',
'repeatable' => TRUE,
'type' => 'template',
'label' => 'Phone',
'title_field' => 'title',
'fields' => array(
'phone' => array('type' => 'phone'),
),
);
$this->form_builder->set_fields($fields);
$this->form_builder->set_field_values($_POST);
$this->form_builder->display_errors = TRUE;
$this->form_builder->required_text = '<span class="required">*</span>required fields';
$vars['form'] = $this->form_builder->render_divs();
$this->fuel->pages->render('contact', $vars);
}
<script>
<?php $this->load->module_view(FUEL_FOLDER, '_blocks/fuel_header_jqx'); ?>
</script>
<?php echo js('fuel/global', 'fuel')?>
<?php echo js('jquery/plugins/jquery-ui-1.8.17.custom.min', 'fuel'); ?>
first_name: First
last_name: Last
email:email@example.com
state:NH
template_phone[0][phone]:789456
template_phone[1][phone]:
Comments
So, digging further into the nested divs and tables ...
<div class="repeatable noclone" data-index="1"> <h3 class="grabber" title=""></h3> <div class="repeatable_content" style="display: none;"> <div class="form" id="form_515adef3d9ec1"> <table><tbody> <tr> <td class="label"><label for="template_phone_1_phone" id="label_template_phone_0_phone">Phone</label></td> <td class="value"><input type="text" name="template_phone[1][phone]" value="" id="template_phone_1_phone" class="field_type_phone field_depth_0" size="40" data-orig_name="template_phone" data-index="1" data-key="phone" data-field_name="template_phone"></td> </tr> <tr> <td></td> <td class="actions"><div class="actions_inner"></div></td> </tr> </tbody></table> </div> </div> <a href="#" class="remove" style="">Remove </a> </div>
I see there is an inline 'style display: none' on the containing div. Is that something controlled via the 'init_display' option? I tried the three option values documented, but saw no change in behavior.
Yes, the 'false' value for the 'init_display' solved the issue. Thank you.
I'll be adding a feature request that the template fields honor the 'render_divs()' method in form builder.
Thanks again for the excellent support!
... $fields['template_phone'] = array( 'display_label' => false, 'add_extra' => false, 'init_display' => 'first', 'dblclick' => 'toggle', 'repeatable' => TRUE, 'type' => 'template', 'label' => 'Phone', 'title_field' => 'title', 'fields' => array( 'phone' => array('type' => 'phone'), ), 'form_builder_params' => array('render_format' => 'divs') );