[wp-trac] [WordPress Trac] #36825: Multiselect feature on attachment_fields_to_edit
WordPress Trac
noreply at wordpress.org
Thu May 12 13:36:00 UTC 2016
#36825: Multiselect feature on attachment_fields_to_edit
----------------------------------------+-----------------------------
Reporter: drosendo | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: 4.5.2
Severity: normal | Keywords:
Focuses: javascript, administration |
----------------------------------------+-----------------------------
Dont know if is bug or not.
When using:
{{{#!php
<?php
add_filter('attachment_fields_to_edit', array($this, 'multi_field'), 10,
2);
add_filter('attachment_fields_to_save', array($this, 'multi_field_save'),
10, 2);
function multi_field($form_fields, $post) {
$current = "something";
$html = "<select name='attachments[{$post->ID}][multi_field]'
id='attachments[{$post->ID}][multi_field]' multiple='multiple'>";
$html .= "<option value='' " . selected($current, '', false) .
">none</option>";
$html .= "<option value='a' " . selected($current, $something, false)
. ">a</option>";
$html .= "<option value='b' " . selected($current, $something, false)
. ">b</option>";
$html .= "<option value='c' " . selected($current, $something, false)
. ">c</option>";
$html .= "<option value='d' " . selected($current, $something, false)
. ">d</option>";
$html .= '</select>';
$form_fields['woosvi-slug'] = array(
'label' => 'Variation',
'input' => 'html',
'html' => $html,
'application' => 'image',
'exclusions' => array(
'audio',
'video'
)
);
return $form_fields;
}
function multi_field_save($post, $attachment) {
if (isset($attachment['multi_field']))
update_post_meta($post['ID'], 'multi_field',
$attachment['multi_field']);
return $post;
}
}}}
Each time the select option is done, it runs ajax and saves the last value
and not multiple values.
May be im missing somehting to allow this to work properly.
thanks,
David
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36825>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list