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


PHP sfWebRequest::setMethod方法代码示例

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


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

示例1: render

 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $class = array('class' => '');
     if (isset($attributes['class'])) {
         $class = array_merge($class, $attributes);
         $attributes['class'] .= ' hidden';
     }
     $class = ' ' . $class['class'];
     $values = array_merge(array('text' => '', 'is_empty' => false), is_array($value) ? $value : array());
     $obj_name = $this->getName($value);
     if ($this->getOption('default_name')) {
         $obj_name = $this->getOption('default_name');
     }
     $input = parent::render($name, $value, $attributes, $errors);
     if (strlen($this->getOption('button_class')) > 0) {
         $class .= ' ' . $this->getOption('button_class');
     }
     if ($this->getOption('button_is_hidden') && $value == 0) {
         $class .= ' hidden';
     }
     $input .= '<div title="' . $this->getOption('box_title') . '" id="' . $this->generateId($name) . '_button" class="ref_name' . $class . '">';
     $in_text = '<span class="on">' . __('Choose !') . '</span>';
     $url_params = '';
     if (count($this->getOption('url_params')) != 0) {
         $url_params = '?';
         foreach ($this->getOption('url_params') as $k => $v) {
             $url_params .= urlencode($k) . '=' . urlencode($v);
         }
     }
     $partial_url_params = '';
     if (count($this->getOption('partial_url_params')) != 0) {
         $partial_url_params = '?';
         foreach ($this->getOption('partial_url_params') as $k => $v) {
             $partial_url_params .= urlencode($k) . '=' . urlencode($v);
         }
     }
     $hidden = ' hidden';
     $json_splited_values = array();
     $rendered_partial = '';
     if (!empty($value)) {
         if (is_int($value) > 0) {
             $json_splited_values[] = array("id" => $value);
             $hidden = '';
         } else {
             $splited_values = preg_split('/[,]/', $value);
             if (count($splited_values) > 0) {
                 $hidden = '';
                 foreach ($splited_values as $split_val) {
                     if (intval($split_val) > 0) {
                         $json_splited_values[] = array("id" => $split_val);
                     }
                 }
             }
         }
     }
     if (count($json_splited_values) > 0) {
         try {
             $context = sfContext::getInstance();
             $partial_request = new sfWebRequest($context->getEventDispatcher());
             $partial_request->setMethod('POST');
             $partial_request->setParameter('field_id', $this->generateId($name));
             $partial_request->setParameter('row_data', $json_splited_values);
             $partial_request->setParameter('from_db', '1');
             $partial_request->setParameter('catalogue', $this->getOption('model'));
             $partial_controler = new sfFrontWebController($context);
             $partial_controler_action = $partial_controler->getAction($this->getOption('partial_controler'), $this->getOption('partial_action'));
             $rendered_partial = $partial_controler_action->execute($partial_request);
         } catch (Exception $e) {
             $hidden = ' hidden';
             $rendered_partial = '';
         }
     }
     $input .= '<a href="' . url_for($this->getOption('link_url')) . $url_params . '" class="but_text_multiple">' . $in_text . '</a>';
     $input .= '</div>';
     $input .= '<div id="' . $this->generateId($name) . '_result_table" class="results_container but_ref_multiple' . $hidden . '">
              <table class="results">
                <thead>
                  <tr>
                    <th>' . __('Name') . '</th>
                    <th>' . __('Level') . '</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>';
     $input .= $rendered_partial;
     $input .= '     </tbody>
              </table>
            </div>
           ';
     $input .= '<script  type="text/javascript">
              $(document).ready(function () {
                $("#' . $this->generateId($name) . '_button a.but_text_multiple").button_ref_multiple({
                  q_tip_text : "Choose a ' . $this->getLabel() . '",
                  update_row_fct: $.fn.button_ref_multiple.addEntry,
                  ids_list_target_input_id: "#' . $this->generateId($name) . '",
                  names_list_target_table_id: "#' . $this->generateId($name) . '_result_table",
                  partial_url:"' . url_for($this->getOption('partial_url')) . $partial_url_params . '",
                  attached_field_id:"' . $this->generateId($name) . '"
                });';
     $on_change_attached_to_id = $this->getOption('on_change_attached_to_id');
//.........这里部分代码省略.........
开发者ID:naturalsciences,项目名称:Darwin,代码行数:101,代码来源:widgetFormButtonRefMultiple.class.php


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