当前位置: 首页>>代码示例>>PHP>>正文


PHP HtmlElement::toHtml方法代码示例

本文整理汇总了PHP中HtmlElement::toHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlElement::toHtml方法的具体用法?PHP HtmlElement::toHtml怎么用?PHP HtmlElement::toHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlElement的用法示例。


在下文中一共展示了HtmlElement::toHtml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tagForm

 /**
  * Render form tags
  * @param boolean binary | if set - renders a multipart form - else a url encoded form.
  * @param string controller | if set - sets the controller of the target url for this form
  * @param string action | if set - sets the action of the target url for this form
  * @param string parms | if set - sets the parameters of the target url for this form
  * @param array|object|json data | A map of data for this form - will be propegated to fields within this form.
  * @param string method | sets the HTTP method to used (post or get) - defaults to post
  * @param string url | sets the url of the form - only used if controller is not set
  * @param string id | sets the id on the form element
  * @param string class | sets the css class for the form element
  */
 protected function tagForm($attrs, $view)
 {
     if ($attrs->binary) {
         $attrs->enctype = 'multipart/form-data';
     } else {
         $attrs->enctype = 'application/x-www-form-urlencoded ';
     }
     if (!$attrs->controller && !$attrs->action && !$attrs->parms) {
         if (!$attrs->controller) {
             $attrs->controller = Pimple::instance()->getController();
             if (!$attrs->action) {
                 $attrs->action = Pimple::instance()->getAction();
             }
         }
         $attrs->url = Url::makeLink($attrs->controller, $attrs->action, $_SERVER['QUERY_STRING']);
     } else {
         if ($attrs->action && $attrs->controller) {
             $attrs->url = Url::makeLink($attrs->controller, $attrs->action, $attrs->parms);
         }
     }
     unset($attrs->binary);
     if ($attrs->data) {
         $this->formData = $this->toObject($attrs->data);
     } else {
         $this->formData = $view->data;
     }
     $attrs->method = strtolower($attrs->method ? $attrs->method : 'post');
     $this->formMethod = $attrs->method;
     $elm = new HtmlElement('form');
     $elm->setAttribute('method', $attrs->method);
     $elm->setAttribute('enctype', $attrs->enctype);
     $elm->setAttribute('action', $attrs->url);
     if ($attrs->id) {
         $elm->setAttribute('id', $attrs->id);
     }
     if ($attrs->class) {
         $elm->setAttribute('class', $attrs->class);
     }
     $elm->addChild(new HtmlText($this->body()));
     return $elm->toHtml();
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:53,代码来源:FormTagLib.php


注:本文中的HtmlElement::toHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。