Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm creating a meta box that'll have repeatable fields, when the user clicks a button to add a new field in the meta box. One of these repeatable fields is a drop down. I would like the dropdown to contain field types e.g. text, textarea. Then the user will be able to select one of these field types from the drop down.

My Q: Have I structured the arrays correctly for this?

add_action ('add_meta_boxes', 'mp_mbe_create' );  
function mp_mbe_create() {  
add_meta_box (  
'mp-meta',  
'Form Fields',   
'mp_mbe_function',  
 'movie_reviews',  
  'normal',   
  'high'  
   );  
}  
$mpprefix =  'Custom_';  
$mp_custom_meta_fields = array(  
array(  
'label' => 'Add New Form',  
'desc' => 'Add new fields to your form here',  
'id' => $mpprefix.'repeatable',  
'type' => 'repeatable',  
'options' => array(  
array (  
'label' => 'Text Box',  
'value' => 'text',  
'type' => 'text',  
),  
array(  
'label' => 'Text Area',  
'value' => 'textarea',  
'type' => 'textarea'  
),  
);  
function mp_mbe_function() {   
global $mp_custom_meta_fields, $post;   
// displays the actual form fields 
share|improve this question
1  
$mp_custom_meta_fields is broken, the arrays don't close. If you indent your code properly, you'll be able to spot this things easily: pastebin.com/dQJZU7fe. What happens when you run your code? –  brasofilo Apr 17 '13 at 23:58
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.