Custom Fields

Camaleon CMS Custom Fields is the perfect solution for any website which needs more flexible data.

Visually create your Fields
Select from multiple input types (text, textarea, wysiwyg, image, file, post object, category object, user object, select, checkbox, radio buttons, date picker, color picker, repeater, translatable, ...)

Assign your grouped fields to categories in a specific content type, , posts in a specific content type, post tags in a specific content type, users, site settings, menus, current theme, single post, or a custom model.

Field Attributes:
Repeater - Permit to enter multiple times the value for the custom field
Required - The value for the custom field is mandatory
Translatable - The value of the custom field can be entered in multiple languages configured for the site

Group Attributes:
name - Title for the Grouped Field
is_repeat - Permit to enter multiple values (duplicate) the current field group
description - Text description for the field group
where to display: Object class where will be added the custom field group

Visual details:
http://camaleon.tuzitio.com/custom-fields-4.html

  • How to add custom fields by code?
    # add a custom field group to current theme
    my_group = current_theme.add_field_group({name: "My Group", slug: "my_group_key"})
    # add a custom field group to specific post type
    my_group = my_post_type.add_field_group({name: "My Group", slug: "my_group_key"})
    # add custom field to specific group
    my_group.add_field({name: "Web Site", slug: "web_site"}, {field_key: "url"})

    # add custom fields into default group multiple support
    current_theme.add_field({"name"=>"Home Slider 3", "slug"=>"home_slider3"}, {field_key: "my_slider", translate: true, multiple: true, default_value: [{"image":"http://camaleon.tuzitio.com/media/132/test_images/screen.shot.2016-05-12.at.6.47.38.pm.png","title":"Slider 1","descr":"This is a sample description"}, {"image":"http://camaleon.tuzitio.com/media/132/test_images/screen.shot.2016-05-12.at.6.47.47.pm.png","title":"Slider 2","descr":"This is a sample description 2"}]})
    # set values multiple kind for previous field (field with multiple values support)
    current_theme.save_field_value("home_slider3", [{"image":"http://camaleon.tuzitio.com/media/132/test_images/screen.shot.2016-05-12.at.6.47.38.pm.png","title":"Slider 1","descr":"This is a sample description"}, {"image":"http://camaleon.tuzitio.com/media/132/test_images/screen.shot.2016-05-12.at.6.47.47.pm.png","title":"Slider 2","descr":"This is a sample description 2"}])
    # set single value (for no multiple support)
    current_theme.save_field_value("home_slider3", 'Single Value')

    # add a custom field no multiple with value for current theme (one line)
    current_theme.add_field({"name"=>"Home Slider 3", "slug"=>"home_slider3"}, {field_key: "my_slider", translate: true, multiple: false, default_value: 'default value'}) # for fields no multiple

    # add a custom field with multiple support and set values for current theme (one line)
    current_theme.add_field({"name"=>"Home Slider 3", "slug"=>"home_slider3"}, {field_key: "my_slider", translate: true, multiple: true, default_values: [{"image":"http://camaleon.tuzitio.com/media/132/test_images/screen.shot.2016-05-12.at.6.47.38.pm.png","title":"Slider 1","descr":"This is a sample description"}, {"image":"http://camaleon.tuzitio.com/media/132/test_images/screen.shot.2016-05-12.at.6.47.47.pm.png","title":"Slider 2","descr":"This is a sample description 2"}]})
  • Samples how to add custom field group to specific models
    # add a custom field group to categories in a specific content type,
    my_group = my_post_type.add_field_group({name: "My Group", slug: "my_group_key"}, 'Category')
    # add a custom field group to posts in a specific content type
    my_group = my_post_type.add_field_group({name: "My Group", slug: "my_group_key"}, 'Post')
    # add a custom field group to post tags in a specific content type
    my_group = my_post_type.add_field_group({name: "My Group", slug: "my_group_key"}, 'PostTag')
    # add a custom field group to all post types
    my_group = my_post_type.add_field_group({name: "My Group", slug: "my_group_key"}, '')
    # add a custom field group to users
    my_group = current_site.custom_field_groups.create(object_class: 'User')
    # add a custom field group to site settings
    my_group = current_site.add_field_group({name: "My Group", slug: "my_group_key"}, '')
    # add a custom field group to menus
    my_group = my_menu.add_field_group({name: "My Group", slug: "my_group_key"}, '')
    # add a custom field group to current theme
    my_group = current_theme.add_field_group({name: "Home Slider", slug: "home_slider", is_repeat: true}) # is_repeat permit to duplicate the field group to enter multiple values
    # add a custom field group to single post
    my_group = current_site.custom_field_groups.create(object_class: 'MyClass')