【问题标题】:Zend Form Radio Elements, using images instead of default radio elementsZend Form Radio Elements,使用图像而不是默认的 radio 元素
【发布时间】:2010-03-19 22:39:25
【问题描述】:

这就是我的最终目标。使用 Zend_Form 我想把这个想法http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/ 变成一个单选按钮列表。

有点使用这个概念。 http://theodin.co.uk/tools/tutorials/jqueryTutorial/fancyRadio/

我知道必须有办法做到这一点,但我似乎无法弄清楚任何事情!有什么想法吗?

谢谢! -d

【问题讨论】:

    标签: php zend-framework zend-form


    【解决方案1】:

    为什么你认为必须有办法?

    你看过源代码吗?第二个可以使用自定义装饰器来完成。阅读一下:

    http://framework.zend.com/manual/1.10/en/learning.form.decorators.html

    澄清问题后补充:

    我有一个类似的问题,我需要为每个单选按钮添加一个预览按钮。我所做的是将完整的 html 插入到传递给 setMultiOptions 的数组中。该列表是动态的。列表中的每个项目都在应用程序的其他地方定义并存储在数据库中。定义这些选项时,用户可以指定上传文件。此文件构成 a 标记中 url 的一部分。这里有一些 SQL 来帮助解释我的意思:

    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);
    }
    

    你可以用 img 标签做类似的事情。这个函数返回的数组可以传递给setMultiOptions:$radio->setMultiOptions($array);

    HTH

    【讨论】:

    • 没有添加更多信息是我的错。这是对我所在位置的更准确描述。我可以轻松地创建一个 ViewScript 文件来自定义我的收音机。问题是我不确定如何为每个选项提取链接和图像等内容。为整个无线电元素拉入链接和图像是没有问题的。
    • 我明白了。我在答案中添加了更多内容。
    猜你喜欢
    • 2011-04-09
    • 1970-01-01
    • 2018-11-04
    • 2018-08-07
    • 2016-04-09
    • 2022-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多