Ejemplo n.º 1
0
 /**
  * Sets the default action invoked on page-form submit
  *
  * This is necessary as the user may just press Enter instead of
  * clicking one of the named submit buttons and then no action name will
  * be passed to the script.
  *
  * @param  string    Default action name
  * @param  string    Path to a 1x1 transparent GIF image
  * @return object    Returns the image input used for default action
  */
 public function setDefaultAction($actionName, $imageSrc = '')
 {
     require_once 'HTML/QuickForm2/Controller/DefaultAction.php';
     if (0 == count($this->form)) {
         $image = $this->form->appendChild(new HTML_QuickForm2_Controller_DefaultAction($this->getButtonName($actionName), array('src' => $imageSrc)));
         // replace the existing DefaultAction
     } elseif ($image = $this->form->getElementById('_qf_default')) {
         $image->setName($this->getButtonName($actionName))->setAttribute('src', $imageSrc);
         // Inject the element to the first position to improve chances that
         // it ends up on top in the output
     } else {
         $it = $this->form->getIterator();
         $it->rewind();
         $image = $this->form->insertBefore(new HTML_QuickForm2_Controller_DefaultAction($this->getButtonName($actionName), array('src' => $imageSrc)), $it->current());
     }
     return $image;
 }