tammyhart / Reusable-Custom-WordPress-Meta-Boxes

177 stars 97 forks source link

Repeatable Fields not working #13

Closed MarioGiancini closed 11 years ago

MarioGiancini commented 11 years ago

I'm having issues with getting repeating fields to work properly. It looks like that section of the code isn't finished. The repeatable case type starts of by calling to a variable $field_titles on line 394 of meta_box.php which is supposed to be an array. But theres nothing in the code or in the mexabox sample file that defines it. It looks like theres supposed to be some sort of attribute to define the format of the repeatable field (text, texarea, image), perhaps another attribute in the repeatable array called "format" ? In this case anyway, I'm looking to create repeatable image upload fields. Anyone have ideas asa how to implement this? I'll try and experiment a little. I'm still a github noob, so I'm not sure if I'm supposed to "Fork" this code or not if I want to show changes...

Caspert commented 11 years ago

I have the same issue. When I would like to use the repeatable field, I get warnings and notices:

Notice: Undefined variable: repeatable_fields in /customers/0/d/a/xxx/httpd.www/wordpress/wp-content/themes/wordpress wp/metaboxes/meta_box.php on line 394 Warning: Invalid argument supplied for foreach() in /customers/0/d/a/xxx/httpd.www/wordpress/wp-includes/functions.php on line 2638 Warning: array_filter() expects parameter 1 to be array, null given in /customers/0/d/a/xxx/httpd.www/wordpress/wp-content/themes/wordpress wp/metaboxes/meta_box.php on line 395 Notice: Undefined variable: repeatable_fields in /customers/0/d/a/xxx/httpd.www/wordpress/wp-content/themes/wordpress wp/metaboxes/meta_box.php on line 408 Warning: Invalid argument supplied for foreach() in /customers/0/d/a/xxx/httpd.www/wordpress/wp-includes/functions.php on line 2638 Warning: array_fill_keys() expects parameter 1 to be array, null given in /customers/0/d/a/xxx/httpd.www/wordpress/wp-content/themes/wordpress wp/metaboxes/meta_box.php on line 409 Fields
Notice: Undefined variable: repeatable_fields in /customers/0/d/a/xxx/httpd.www/wordpress/wp-content/themes/wordpress wp/metaboxes/meta_box.php on line 415 Warning: Invalid argument supplied for foreach() in /customers/0/d/a/xxx/httpd.www/wordpress/wp-content/themes/wordpress wp/metaboxes/meta_box.php on line 415
Fields

Hope they can fixed. Look out to your response.

Casper

oterox commented 11 years ago

you can add repeatable fields this way:

array(  // Repeatable & Sortable Text inputs
    'label' => 'Typical Day', // 

But there's another problem: the repeatables are not saved and i don't know how to fix that

Caspert commented 11 years ago

Woow, nice thank you for your response. I will check it out. I read the tutorial of the author, she will explain how to save an input, so I think that's great to combine. ;)

tammyhart commented 11 years ago

The repeatables should be saving because the save callback just uses the fields from the same array. However, there are probably a few holes and errors in there that I've along ago fixed, just haven't been the best at keeping this updated. Mostly because my improvements are being made within a client's project, so it's not so easy to port back and forth.

I'm also working on moving the fields into their own function so that when you come to a repeatable, there's no need to redo the same code for each field, it will just repeat the function. This would technically allow for indefinite repeatables, but would pose problems in the UI and javascript structure, so I'm still working out those potential bugs.

tammyhart commented 11 years ago

Okay, I've just updates how these works. The only remaining known issue is an unidentified index notice for unchecked checkboxes. I'll circle back to that later.

oterox commented 11 years ago

Cool! now it works, thank you very much tammy for fixing the issues.