Skip to content

Instantly share code, notes, and snippets.

@anointed
Created June 21, 2012 18:42
Show Gist options
  • Select an option

  • Save anointed/2967677 to your computer and use it in GitHub Desktop.

Select an option

Save anointed/2967677 to your computer and use it in GitHub Desktop.
Radio Image type
Here is an example 'radio image' field type.
Notice that we are giving the user a set number of choices for the sidebar via 'radio buttons', but instead of showing the text next to the radio box, we are showing an image.
This is from http://leemason.github.com/NHP-Theme-Options-Framework/
One other question:
Is there an ability to create a 'group' of repeating fields?
i.e.
group contains field types (text-title, image, description, etc) where I create that block of fields, and that entire block can repeat?
Idea using metabox as a slideshow input, where the user gives each image a title and description. After inputting all the info for the image, click 'add another', where you get another field set.
thanks so much for your time and for the great script.
array(
'id' => 'default_single_post_layout',
'type' => 'radio_img',
'title' => __('default_single_post_layout', 'tumble'),
'sub_desc' => __('No validation can be done on this field type', 'tumble'),
'desc' => __('This uses some of the built in images, you can use them for layout options.', 'tumble'),
'options' => array(
'no-sidebar' => array('title' => 'No Sidebar', 'img' => NHP_OPTIONS_URL.'img/1col.png'),
'sidebar-left' => array('title' => 'Sidebar Left', 'img' => NHP_OPTIONS_URL.'img/2cl.png'),
'sidebar-right' => array('title' => 'Sidebar Right', 'img' => NHP_OPTIONS_URL.'img/2cr.png')
),//Must provide key => value(array:title|img) pairs for radio options
'std' => 'sidebar-left'
@rilwis

rilwis commented Jun 22, 2012

Copy link
Copy Markdown

Hi

We don't have the 'radio image' field type now. But you can achieve that by using one of the following filter:

$field_html = apply_filters( "rwmb_{$type}_html", $field_html, $field, $meta );
$field_html = apply_filters( "rwmb_{$id}_html", $field_html, $field, $meta );

Where field_html is the HTML content of the field (<input>, <select>, etc.); id is the field ID, type is the field type, field is the array of field attribute, meta is the field value.

For group of repeating fields, we haven't implemented it yet. So, it's not available now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment