Zend Form Radio Elements, using images instead of default radio elements
Ultimately here is my goal. Using Zend_Form I want to开发者_运维问答 turn this idea http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/ into a list of radio buttons.
Kind of using this concept. http://theodin.co.uk/tools/tutorials/jqueryTutorial/fancyRadio/
I know there has to be a way to do this but I can't seem to figure anything out! Any ideas?
Thanks! -d
Why do you think there has to be a way?
Did you have a look at the source code? The second one might be done using custom decorators. Have a read about that:
http://framework.zend.com/manual/1.10/en/learning.form.decorators.html
More added after clarifying question:
I had a similar problem where I needed to add a preview button to each radio button. What I did was insert the complete html into the array passed to setMultiOptions. The list is dynamic. Each item on the list is defined elsewhere in the app and stored in the database. When defining these options, the user can specify to up load a file. This file forms part of the url in the a tag. Here is a bit of SQL to help explain what I mean:
function readAllObjlistitemPairpreview($id)
{
// get all objlistitem rows that belong to a certain list
$id = (int)$id;
$select = $this->getAdapter()->select()->from(array('li' => 'objlistitem'), array())->join(array('i' => 'objitem'), 'li.objitem = i.id', array('id' => 'li.objitem', 'name' => "CONCAT(i.name, ' <a href=\"', i.url, '\">url</a>')"))->where('li.objlist = ?', $id);
//return $this->getAdapter()->fetchAll($select);
return $this->getAdapter()->fetchPairs($select);
}
You could do something similar with an img tag. The array that this function returns can be passed to setMultiOptions: $radio->setMultiOptions($array);
HTH
精彩评论