Radio buttons and default values


I've just filed this on GitHub, but I was wondering if I was wrong.

How do you use Phalcon\Forms\Element\Radio so that you can have default values working?

Okay, I've come up with a solution, hope it'll help. Inside form class:

$this->add(new Radio('published'));

And then in view:

{{ form.render('publish', ['value':'Y'])  }}
{{ form.render('publish', ['value':'N'])  }}
edited Oct '14

For default values, or values from request just use \Phalcon\Tag($tagId,$value) like this:

For set values in radio use this:

$radioElement = new Radio('published',array('value' => 'Y'));

For default pre-choosed values:

\Phalcon\Tag::setDefault('published','Y'); // this will select Radio with value Y

From request or model you can do somethig like this:

   \Phalcon\Tag::setDefault('published',$this->request->getPost('published'); // and this will set the value which is selected

Then you can se more than one default values like this:

      'tagId'         => 'value',
      'tagId1'        => 'value1'

I hope this helps. :))

Otherwise, you have an error in names, in form you initializing "published" and in template you trying to access "publish" when you dont have created the "publish" element in form then will be not rendered.