Skip to content

Commit

Permalink
Add Form\Element\Radio
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Garbé committed Mar 11, 2014
1 parent 6e5df22 commit 7623dfb
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Forms/Element/Radio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2012 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to [email protected] so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: Andres Gutierrez <[email protected]> |
| Eduar Carvajal <[email protected]> |
| Nikita Vershinin <[email protected]> |
| Ludomir Crotet <[email protected]> |
| Olivier Garbé <[email protected]> |
+------------------------------------------------------------------------+
*/

namespace Phalcon\Forms\Element {

/**
* Phalcon\Forms\Element\Radio
*
* Component INPUT[type=radio] for forms
*/

class Radio extends \Phalcon\Forms\Element implements \Phalcon\Forms\ElementInterface {

/**
* \Phalcon\Forms\Element constructor
*
* @param string $name
* @param array $attributes
*/
public function __construct($name, $attributes=null) {
parent::__construct($name, $attributes);
}

/**
* Renders the element widget returning html
*
* @param array $attributes
* @return string
*/
public function render($attributes = null){
$render = '';
foreach ($attributes->set->items as $key => $item) {
$render .= \Phalcon\Tag::radioField(array($this->getName(), 'value' => $key)).'&nbsp;'.$item.'&nbsp;';
}
return $render;
}
}
}

0 comments on commit 7623dfb

Please sign in to comment.