2017 © Pedro Peláez
 

olympus-field olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Zeus Core framework.

image

getolympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Zeus Core framework.

  • Saturday, March 17, 2018
  • by crewstyle
  • Repository
  • 1 Watchers
  • 0 Stars
  • 176 Installations
  • HTML
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

, (*1)

Dionysos Radio Field

Olympus Component ![CodeFactor Grade][codefactor-image] Packagist Version ![MIT][license-image], (*2)

This component is a part of the Olympus Dionysos fields for WordPress., (*3)

composer require getolympus/olympus-dionysos-field-radio

Table of contents

Field initializationVariables definitionTexts definitionRetrive dataRelease historyContributing, (*4)


Field initialization

Use the following lines to add a radio field in your WordPress admin pages or custom post type meta fields:, (*5)

return \GetOlympus\Dionysos\Field\Radio::build('my_radio_field_id', [
    'title'       => 'Select a Minion that you may know',
    'default'     => 'kevin',
    'description' => 'A very important question! Pay attention to it ;)',
    'mode'        => 'default',
    'options'     => [
        'kevin' => 'Kevin',
        'mel'   => 'Mel',
        'dave'  => 'Dave',
        'bob'   => 'Bob',
    ],

    /**
     * Texts definition
     * @see the `Texts definition` section below
     */
    't_no_options' => 'The field does no have any options.',
]);

Variables definition

The display depends on the mode value: - set to default (or inline), labels options will be displayed on the same line, as an inline-block display - set to block, labels options will be displayed each per line, as a block display - set to image, labels options will be displayed as default mode, with images and overlay text label - set to image-block, labels options will be displayed as block mode, with images and overlay text label - set to group, labels options will be displayed as a simple but efficient group of choices, (*6)

Variable Type Default value if not set Accepted values
title String 'Radio button' empty
default String empty string One of the options keys
description String empty empty
mode String default see Variables definition
options Array empty Array with a key/value options

Texts definition

Code Default value Definition
t_no_options The field does no have any options. Used as an error in the case no options have been set

Retrive data

Retrieve your value from Database with a simple get_option('my_radio_field_id', '') (see WordPress reference):, (*7)

// Get radio from Database
$radio = get_option('my_radio_field_id', '');

// Display value
echo '

'.$radio.', master of the ceremony

';

Image mode

To display images instead of simple labels, set the mode to image and build the field's options as follow:, (*8)

$options = [
    'key-name' => [
        'label' => 'Label item',
        'image' => 'https://label-image-url',
    ],
];

Below, a full example:, (*9)

return \GetOlympus\Dionysos\Field\Radio::build('my_radio_field_id', [
    'title'       => 'Select a Minion that you may know',
    'default'     => 'dave',
    'description' => 'A very important question! Pay attention to it ;)',
    'mode'        => 'image',
    'options'     => [
        'kevin' => [
            'label' => 'Kevin',
            'image' => 'https://vignette.wikia.nocookie.net/despicableme/images/1/1d/Kevin_minions.png/revision/latest/scale-to-width-down/350?cb=20170703052012',
        ],
        'mel'   => [
            'label' => 'Mel',
            'image' => 'https://vignette.wikia.nocookie.net/despicableme/images/2/2e/Mel_Minion_01.png/revision/latest/scale-to-width-down/350?cb=20160717135212',
        ],
        'dave'  => [
            'label' => 'Dave',
            'image' => 'https://vignette.wikia.nocookie.net/despicableme/images/7/71/Daveholdingcupcake.png/revision/latest/scale-to-width-down/350?cb=20130717145735',
        ],
        'bob'   => [
            'label' => 'Bob',
            'image' => 'https://vignette.wikia.nocookie.net/despicableme/images/c/ca/Bob-from-the-minions-movie.jpg/revision/latest/scale-to-width-down/350?cb=20151224154354',
        ],
    ],

    /**
     * Texts definitions
     * @see the `Texts definitions` section below
     */
    't_no_options' => 'The field does no have any options.',
]);

Release History

Version Note
0.0.19 Remove Checkbox mode from field
0.0.18 Fix image label display for small images
0.0.17 Add group mode with native WordPress display

Contributing

  1. Fork it (https://github.com/GetOlympus/olympus-dionysos-field-radio/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Built with ♥ by Achraf Chouk ~ (c) since a long time., (*10)

The Versions

17/03 2018

dev-master

9999999-dev https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Zeus Core framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus zeus hera

17/03 2018

v0.0.8

0.0.8.0 https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Zeus Core framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus zeus

02/02 2018

v0.0.7

0.0.7.0 https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus hera

02/02 2018

v0.0.6

0.0.6.0 https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus hera

08/10 2016

v0.0.5

0.0.5.0 https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus hera

26/06 2016

v0.0.4

0.0.4.0 https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus hera

10/05 2016

v0.0.3

0.0.3.0 https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus hera

05/05 2016

v0.0.2

0.0.2.0 https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus hera

29/04 2016

v0.0.1

0.0.1.0 https://github.com/GetOlympus/olympus-radio-field

[READ-ONLY] Radio field, this component is a part of the Olympus Hera WordPress library.

  Sources   Download

MIT

The Requires

 

The Development Requires

framework php field radio olympus hera