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


PHP FormUI::control_id方法代码示例

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


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

示例1: from_html

 /**
  * Create a form with controls from HTML
  * @param string $name Name of the form
  * @param string $html HTML of a form
  * @return FormUI The form created from the supplied HTML
  */
 public static function from_html($name, $html)
 {
     $dom = new HTMLDoc($html);
     $form = new FormUI($name);
     // Set the form to render using the output of the HTMLDoc
     $form->settings['norender'] = true;
     $form->settings['content'] = function () use($dom) {
         return $dom->get();
     };
     $form->dom = $dom;
     // This form's id is an MD5 hash of the original HTML
     $form->settings['control_id'] = md5($html);
     // Add the _form_id and WSSE elements to the form
     // Note that these additional fields must be XML-safe, or they won't be added
     $dom->find_one('form')->append_html(Utils::setup_wsse());
     $dom->find_one('form')->append_html('<input type="hidden" name="_form_id" value="' . $form->control_id() . '" />');
     // Add synthetic controls for any found inputs
     foreach ($dom->find('input') as $input) {
         /** @var FormControl $control */
         $form->append($control = FormControlDom::create($input->name)->set_node($input));
         if ($input->data_validators) {
             foreach (explode(' ', $input->data_validators) as $validator) {
                 $control->add_validator($validator);
             }
         }
     }
     foreach ($dom->find('textarea') as $input) {
         /** @var FormControl $control */
         $form->append($control = FormControlDom::create($input->name)->set_node($input));
         if (!empty($input->data_validators)) {
             foreach (explode(' ', $input->data_validators) as $validator) {
                 $control->add_validator($validator);
             }
         }
     }
     return $form;
 }
开发者ID:habari,项目名称:system,代码行数:43,代码来源:formui.php


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