widget() public method

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.
public widget ( string $name, array $data = [] ) : string
$name string The name of the widget. e.g. 'text'.
$data array The data to render.
return string
コード例 #1
0
 public function widget($name, array $data = [])
 {
     return parent::widget($name, $this->_getDefaultTemplateVars($data));
 }
コード例 #2
0
 /**
  * Overridden to pass FormHelper context-specific data.
  *
  * @param string $name widget name
  * @param array $data config data
  * @return string
  */
 public function widget($name, array $data = [])
 {
     $data['horizontal'] = $this->_isHorizontal;
     if (isset($data['help'])) {
         $helpType = 'inline';
         $helpText = '';
         if ($data['horizontal']) {
             $helpType = 'block';
         }
         if (is_array($data['help'])) {
             $helpText = $data['help']['text'];
             $helpType = $data['help']['type'];
         } else {
             $helpText = $data['help'];
         }
         $help = '<span class="help-' . $helpType . '">' . $helpText . '</span>';
         $data['help'] = $help;
     }
     return parent::widget($name, $data);
 }