public function testSaveCustomFieldsArray()
 {
     $my_product_id = 21;
     $vals = array('Red', 'Blue', 'Green');
     $custom_field = array('field_name' => 'Color', 'field_value' => $vals, 'field_type' => 'dropdown', 'content_id' => $my_product_id);
     //adding a custom field "Color" to product
     $new_id = save_custom_field($custom_field);
     $field = get_custom_field_by_id($new_id);
     $to_delete = array('id' => $new_id);
     $delete = delete_custom_field($to_delete);
     $this->assertEquals($field['name'], 'Color');
     $this->assertEquals($field['type'], 'dropdown');
     $this->assertEquals($field['value'], $vals);
     $this->assertEquals(intval($delete) > 0, true);
 }
示例#2
0
<?php

$field = false;
if (isset($params['field-id'])) {
    $field = get_custom_field_by_id($params['field-id']);
}
?>
<script>

        mw.on.moduleReload('<?php 
print $params['id'];
?>
', function(){
            mw.admin.custom_fields.initValues(mwd.getElementById('<?php 
print $params['id'];
?>
').querySelectorAll('.mw-admin-custom-field-name-edit-inline, .mw-admin-custom-field-value-edit-inline'));
        });

 </script>
 
 
 
<?php 
if (isset($field['type']) and ($field['type'] == 'select' or $field['type'] == 'dropdown' or $field['type'] == 'checkbox' or $field['type'] == 'radio')) {
    if (isset($field['values']) and is_array($field['values'])) {
        $vals = $field['values'];
    } elseif (isset($field['value'])) {
        $vals = $field['value'];
    } else {
        $vals = '';