Ejemplo n.º 1
0
 /**
  * @param Customweb_IForm $form
  */
 public function __construct(Customweb_IForm $form = null)
 {
     if ($form !== null) {
         $this->setButtons($form->getButtons())->setElementGroups($form->getElementGroups())->setId($form->getId())->setMachineName($form->getMachineName())->setRequestMethod($form->getRequestMethod())->setTargetUrl($form->getTargetUrl())->setTargetWindow($form->getTargetWindow())->setTitle($form->getTitle());
     } else {
         $this->id = Customweb_Util_Rand::getUuid();
     }
 }
Ejemplo n.º 2
0
 /**
  * This method stores the form data into the storage backend with the right
  * keys according to the current store hierarchy.
  * 
  * @param Customweb_IForm $form
  * @param array $formData
  * @return void
  */
 public function processForm(Customweb_IForm $form, array $formData)
 {
     foreach ($form->getElements() as $element) {
         if ($element->getControl() instanceof Customweb_Form_Control_IEditableControl) {
             $key = implode('_', $element->getControl()->getControlNameAsArray());
             if ($element->isGlobalScope()) {
                 $value = $element->getControl()->getFormDataValue($formData);
                 if ($value === null) {
                     $this->getStorage()->remove(self::STORAGE_SPACE_KEY, $key);
                 } else {
                     $this->getStorage()->write(self::STORAGE_SPACE_KEY, $key, $value);
                 }
             } else {
                 $storageKeyName = $this->getCurrentStoreHierarchySettingKey($key);
                 if ($this->getConfiguration()->useDefaultValue($element, $formData)) {
                     $this->getStorage()->remove(self::STORAGE_SPACE_KEY, $storageKeyName);
                 } else {
                     $value = $element->getControl()->getFormDataValue($formData);
                     if ($value === null) {
                         $this->getStorage()->remove(self::STORAGE_SPACE_KEY, $storageKeyName);
                     } else {
                         $this->getStorage()->write(self::STORAGE_SPACE_KEY, $storageKeyName, $value);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
    public function renderForm(Customweb_IForm $form)
    {
        $output = '<form class="' . $this->getFormCssClass() . '" action="' . $form->getTargetUrl() . '" method="' . $form->getRequestMethod() . '"
				target="' . $form->getTargetWindow() . '" id="' . $form->getId() . '" name="' . $form->getMachineName() . '">';
        $output .= $this->renderElementGroups($form->getElementGroups());
        $token = $this->getFormToken($form);
        if ($token !== null) {
            $output .= '<input type="hidden" name="' . self::FORM_TOKEN_FIELD_NAME . '" value="' . $token . '" />';
        }
        $output .= $this->renderButtons($form->getButtons());
        $output .= '</form>';
        if ($this->isAddJs()) {
            $output .= '<script type="text/javascript">' . "\n";
            $output .= $this->renderElementsJavaScript($form->getElements());
            $output .= "\n</script>";
        }
        return $output;
    }
    public function renderForm(Customweb_IForm $form)
    {
        $this->formId = $form->getId();
        $output = '<div class="content-header"><table cellspacing="0"><tbody><tr><td><h3>' . $form->getTitle() . '</h3></td>';
        $output .= '<td class="form-buttons">';
        $output .= $this->renderButtons($form->getButtons());
        $output .= '</td>';
        $output .= '</tr></tbody></table></div>';
        $output .= '<form class="' . $this->getFormCssClass() . '" action="' . $form->getTargetUrl() . '" method="' . $form->getRequestMethod() . '" 
				target="' . $form->getTargetWindow() . '" id="' . $form->getId() . '" name="' . $form->getMachineName() . '">';
        $output .= '<div class="entry-edit">';
        $output .= $this->renderElementGroups($form->getElementGroups());
        $output .= '</div>';
        $output .= '<input type="hidden" name="form_key" value="' . Mage::getSingleton('core/session')->getFormKey() . '" />';
        $output .= '<input type="hidden" name="button" id="' . $form->getId() . '-button" value="" />';
        $output .= '</form>';
        if ($this->isAddJs()) {
            $output .= '<script type="text/javascript">' . "\n";
            $output .= '$$(\'.use-default-checkbox\').each(function(element){ toggleValueElements(element, Element.previous(element.parentNode)); });' . "\n";
            $output .= $this->renderElementsJavaScript($form->getElements());
            $output .= "\n</script>";
        }
        return $output;
    }