Development

Changeset 23196

You must first sign up to be able to contribute.

Changeset 23196

Show
Ignore:
Timestamp:
10/19/09 20:22:27 (5 months ago)
Author:
Kris.Wallsmith
Message:

[1.3] added form errors to WDT view panel (closes #7371)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.3/lib/debug/sfWebDebugPanelView.class.php

    r22955 r23196  
    135135   * Renders information about the passed template and its parameters. 
    136136   *  
     137   * The rendered HTML for each parameter is filtered through the "debug.web.view.filter_parameter_html" event. 
     138   *  
    137139   * @param  string $file       The template file path 
    138140   * @param  array  $parameters 
     
    223225    $i++; 
    224226 
     227    if ($form->hasErrors() && sfLogger::NOTICE < $this->getStatus()) 
     228    { 
     229      $this->setStatus(sfLogger::NOTICE); 
     230    } 
     231 
    225232    $html = array(); 
    226     $html[] = $this->getParameterDescription($name, $form); 
     233    $html[] = $this->getParameterDescription($name, $form, $form->hasErrors() ? '<code class="sfWebDebugWarning">$%s</code>' : null); 
    227234    $html[] = $this->getToggler('sfWebDebugViewForm'.$i); 
    228235    $html[] = '<div id="sfWebDebugViewForm'.$i.'" style="display:none">'; 
     236 
     237    foreach ($form->getGlobalErrors() as $error) 
     238    { 
     239      $html[] = sprintf('<p><span class="sfWebDebugWarning">%s</span></p>', $error); 
     240    } 
     241 
    229242    $html[] = '<ul>'.$this->formatFormFieldSchemaAsHtml($form->getFormFieldSchema(), $name.'[%s]').'</ul>'; 
    230243    $html[] = '</div>'; 
     
    254267      else 
    255268      { 
    256         $html[] = '<li>'.$this->getParameterDescription($name, $field->getWidget()).'</li>'; 
     269        $html[] = '<li>'; 
     270        $html[] = $this->getParameterDescription($name, $field->getWidget()); 
     271 
     272        if ($field->hasError()) 
     273        { 
     274          $html[] = sprintf('<p><span class="sfWebDebugWarning">%s</span></p>', $field->getError()); 
     275        } 
     276 
     277        $html[] = '</li>'; 
    257278      } 
    258279    } 
     
    269290   * @return string 
    270291   */ 
    271   protected function getParameterDescription($name, $parameter) 
    272   { 
    273     return sprintf('<code>$%s</code> <span class="sfWebDebugDataType">(%s)</span>', $name, is_object($parameter) ? $this->formatFileLink(get_class($parameter)) : gettype($parameter)); 
     292  protected function getParameterDescription($name, $parameter, $nameFormat = null, $typeFormat = null) 
     293  { 
     294    if (null === $nameFormat) 
     295    { 
     296      $nameFormat = '<code>$%s</code>'; 
     297    } 
     298 
     299    if (null === $typeFormat) 
     300    { 
     301      $typeFormat = '<span class="sfWebDebugDataType">(%s)</span>'; 
     302    } 
     303 
     304    return sprintf($nameFormat.' '.$typeFormat, $name, is_object($parameter) ? $this->formatFileLink(get_class($parameter)) : gettype($parameter)); 
    274305  } 
    275306 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.