Subversion Repositories owmoduleforms

[/] [trunk/] [classes/] [formelements/] [owformsubmit.php] - Diff between revs 26 and 32

Show entire file | Ignore whitespace | Details | Blame | View Log

Rev 26 Rev 32
Line 4... Line 4...
{
{
 
    var $type='submit';
 
   
    public function __construct($options=array())
    public function __construct($options=array())
    {
    {
        $this->setDefaultOption($options, 'name', 'submit');
        $this->setDefaultOption($options, 'name', 'submit');
        $this->setDefaultOption($options, 'class', 'button');
        $this->setDefaultOption($options, 'class', 'button');
        $this->setDefaultOption($options, 'template_name', 'submit_confirm.tpl');
        $this->setDefaultOption($options, 'template_path', 'owmoduleforms/submit_confirm.tpl');
        $this->setDefaultOption($options, 'variables', array('confirm_message' => 'Form successfully submitted!'));
        $this->setDefaultOption($options, 'variables', array('confirm_message' => 'Form successfully submitted!'));
        parent::__construct($options);
        parent::__construct($options);
    }
    }
 
 
    public function getSubmittedButton()
    public function getSubmittedButton()
    {
    {
        return array_key_exists($this->getName(), $_REQUEST) ? $this : false;
        return array_key_exists($this->getName(), $_REQUEST) ? $this : false;
    }
    }
 
 
    public function renderSubmit($form)
    public function setVariablesToTemplate($form, $tpl)
    {
    {
        $tpl = $form->getFormTemplate();
 
        $variables = $this->getOption('variables');
 
        foreach ($variables as $variable_name => $variable_value)
 
        {
 
            $tpl->setVariable($variable_name, $variable_value);
 
        }
 
        $submitted_data = array();
        $submitted_data = array();
        foreach($form->getSubmittedData() as $element)
        foreach($form->getSubmittedData() as $element)
        {
        {
            $name = $element->getName();
            $name = $element->getName();
            $submitted_data[$name] = array(
            $submitted_data[$name] = array(
                'label' => $element->getLabel() ? $element->getLabel() : $name,
                'label' => $element->getLabel() ? $element->getLabel() : $name,
                'type' => get_class($element),
                'type' => get_class($element),
                'value' => $element->getValue(),
                'value' => $element->getValue(),
            );
            );
           
 
        }
        }
        $tpl->setVariable('submitted_data', $submitted_data);
        $tpl->setVariable('submitted_data', $submitted_data);
        return $tpl->fetch('design:owmoduleforms/'.$this->getOption('template_name'));
    }
 
 
 
    public function renderSubmit($form)
 
    {
 
        $tpl = $form->getFormTemplate();
 
        $variables = $this->getOption('variables');
 
        foreach ($variables as $variable_name => $variable_value)
 
        {
 
            $tpl->setVariable($variable_name, $variable_value);
 
        }
 
        $this->setVariablesToTemplate($form, $tpl);
 
        return $tpl->fetch('design:'.$this->getOption('template_path'));
    }
    }
 
 
    public function submit($form)
    public function submit($form)
    {
    {
        $form->validate($form->getHttpFormMethod());
        $form->validate($form->getHttpFormMethod());