1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage Form
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 JFormHelper::loadFieldClass('list');
13
14 /**
15 * Form Field class for the Joomla Platform.
16 * Provides radio button inputs
17 *
18 * @link http://www.w3.org/TR/html-markup/command.radio.html#command.radio
19 * @since 11.1
20 */
21 class JFormFieldRadio extends JFormFieldList
22 {
23 /**
24 * The form field type.
25 *
26 * @var string
27 * @since 11.1
28 */
29 protected $type = 'Radio';
30
31 /**
32 * Name of the layout being used to render the field
33 *
34 * @var string
35 * @since 3.5
36 */
37 protected $layout = 'joomla.form.field.radio';
38
39 /**
40 * Method to get the radio button field input markup.
41 *
42 * @return string The field input markup.
43 *
44 * @since 11.1
45 */
46 protected function getInput()
47 {
48 if (empty($this->layout))
49 {
50 throw new UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
51 }
52
53 return $this->getRenderer($this->layout)->render($this->getLayoutData());
54 }
55
56 /**
57 * Method to get the data to be passed to the layout for rendering.
58 *
59 * @return array
60 *
61 * @since 3.5
62 */
63 protected function getLayoutData()
64 {
65 $data = parent::getLayoutData();
66
67 $extraData = array(
68 'options' => $this->getOptions(),
69 'value' => (string) $this->value,
70 );
71
72 return array_merge($data, $extraData);
73 }
74 }
75