doudi2833 2013-12-26 12:03
浏览 13

zf2中的占位符属性

How could insert the value of a field's db in the plcaholder in zf2

<div class="form_element">
<?php
    $this->placeholder('name')->data = $this->data;  
    $name = $form->get('name');
    echo $formLabel->openTag().$name->getOption('label')." ";   
        echo $this->formInput($name);
        echo $formLabel->closeTag();
?>
</div>
  • 写回答

1条回答 默认 最新

  • dpx49470 2013-12-26 15:12
    关注

    A placeholder is a ViewHelper and therefore is is designed to help render view content.

    In order to use your database data witin a placeholder you will need to ensure that the data is first passed to the view from the controller action.

    public function modificaAlumnoAction()
    {
      //...
      return ViewModel('data' => $data); // data passed to the view instance 
    }
    

    Then within the view script

    // modifica-alumno.phtml
    $this->placeholder('foo')->data = $this->data;
    

    An finally output the data (such as within the layout)

    // layout.phtml
    echo $this->placeholder('foo)->data;
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度