예제 #1
0
 /**
  * Render a named widget.
  *
  * This is a lower level method. For built-in widgets, you should be using
  * methods like `text`, `hidden`, and `radio`. If you are using additional
  * widgets you should use this method render the widget without the label
  * or wrapping div.
  *
  * @param string $name The name of the widget. e.g. 'text'.
  * @param array $data The data to render.
  * @return string
  */
 public function widget($name, array $data = [])
 {
     $secure = null;
     if (isset($data['secure'])) {
         $secure = $data['secure'];
         unset($data['secure']);
     }
     $widget = $this->_registry->get($name);
     $out = $widget->render($data, $this->context());
     if (isset($data['name']) && $secure !== null && $secure !== self::SECURE_SKIP) {
         foreach ($widget->secureFields($data) as $field) {
             $this->_secure($secure, $this->_secureFieldName($field));
         }
     }
     return $out;
 }
예제 #2
0
 /**
  * Render a named widget.
  *
  * This is a lower level method. For built-in widgets, you should be using
  * methods like `text`, `hidden`, and `radio`. If you are using additional
  * widgets you should use this method render the widget without the label
  * or wrapping div.
  *
  * @param string $name The name of the widget. e.g. 'text'.
  * @param array $data The data to render.
  * @return string
  */
 public function widget($name, array $data = [])
 {
     $widget = $this->_registry->get($name);
     if (isset($data['secure'], $data['name']) && $data['secure'] !== self::SECURE_SKIP) {
         foreach ($widget->secureFields($data) as $field) {
             $this->_secure($data['secure'], $this->_secureFieldName($field));
         }
     }
     unset($data['secure']);
     return $widget->render($data, $this->context());
 }
예제 #3
0
 /**
  * Test getting resolve dependency missing dependency
  *
  * @expectedException \RuntimeException
  * @expectedExceptionMessage Unknown widget "label"
  * @return void
  */
 public function testGetResolveDependencyMissingDependency()
 {
     $inputs = new WidgetRegistry($this->templates, $this->view);
     $inputs->clear();
     $inputs->add(['multicheckbox' => ['Cake\\View\\Widget\\MultiCheckboxWidget', 'label']]);
     $inputs->get('multicheckbox');
 }
예제 #4
0
 /**
  * Render a named widget.
  *
  * This is a lower level method. For built-in widgets, you should be using
  * methods like `text`, `hidden`, and `radio`. If you are using additional
  * widgets you should use this method render the widget without the label
  * or wrapping div.
  *
  * @param string $name The name of the widget. e.g. 'text'.
  * @param array $data The data to render.
  * @return string
  */
 public function widget($name, array $data = [])
 {
     return $this->_registry->get($name)->render($data);
 }