-
Notifications
You must be signed in to change notification settings - Fork 87
Reapeater Field
nosurs edited this page Jun 13, 2014
·
3 revisions
#Repeater Field
To add a Repeater block field to your metabox first create an array of fields and then use the addRepeaterBlock method of the metabox object:
$my_meta = new AT_Meta_Box($config);
$repeater_fields[] = $my_meta->addText('re_text_field_id',array('name'=> 'My Text '),true);
$repeater_fields[] = $my_meta->addTextarea('re_textarea_field_id',array('name'=> 'My Textarea '),true);
$my_meta->addRepeaterBlock('re_',array('inline' => true, 'name' => 'This is a Repeater Block','fields' => $repeater_fields));- ID: field id (string)
-
args: (mixed|array)
-
'_name_' => field name/label, (string) optional -
'_desc_' => field description, (string) optional -
'_std_' => default value, (string) optional -
'_style_' => custom style for field, (string) optional -
'_validate_func_' => validate function name, (string) optional -
'_fields_' => fields to repeat (array) -
'_inline_' => show all fields in one row (bool) optional (default false) -
'_sortable_' => make fields sortable (bool) optional (default false)
-
- repeater: When adding this field to a repeater block set to true (default false)
The Repeater fields are stored the as an array in the database so to echo them out them use:
$saved_data = get_post_meta($post->ID,'re_',true);
foreach ($saved_data as $arr){
echo $arr['re_text_field_id'];
echo $arr['re_textarea_field_id'];
}