146 |
* doing the form processing |
* doing the form processing |
147 |
*/ |
*/ |
148 |
function _process_form() { |
function _process_form() { |
149 |
//let the form build the FormElement objects |
$this->_init_form_content(); |
|
//that will be used by the form |
|
|
$this->_form_content->form_init_elements(); |
|
|
|
|
|
//first we need to |
|
|
if (!@$_REQUEST[FORM_VISITED]) { |
|
|
$this->_form_content->form_init_data(); |
|
|
} |
|
|
|
|
150 |
|
|
151 |
//we only need to process the form |
//we only need to process the form |
152 |
//if it has been visited. Otherwise |
//if it has been visited. Otherwise |
155 |
$this->_set_action(); |
$this->_set_action(); |
156 |
|
|
157 |
//let see if this was a confirmation page. |
//let see if this was a confirmation page. |
158 |
if ( !empty($_REQUEST[FORM_CONFIRM]) && $_REQUEST[FORM_CONFIRM] == 1 ) { |
if ( !empty($_REQUEST[FORM_CONFIRM]) ) { |
159 |
//looks like this was a submit on a |
if ($_REQUEST[FORM_CONFIRM] == 1) { |
160 |
//confirmation page. we don't need |
//looks like this was a submit on a |
161 |
//to do form field validation. |
//confirmation page. we don't need |
162 |
$this->_confirmed = TRUE; |
//to do form field validation. |
163 |
|
$this->_confirmed = TRUE; |
164 |
|
} else { |
165 |
|
//looks like the confirmation was aborted. |
166 |
|
xxx("aborted"); |
167 |
|
} |
168 |
} |
} |
169 |
|
|
170 |
//now do the validation |
//now do the validation |
224 |
* confirmation page is rendered |
* confirmation page is rendered |
225 |
*/ |
*/ |
226 |
function _pre_confirm() { |
function _pre_confirm() { |
227 |
|
|
228 |
|
if ($this->_form_content->_has_file_element) { |
229 |
|
//we need to allow any/all of the file elements |
230 |
|
//save the temp files during a confirmation. |
231 |
|
//if we don't, then the web server may delete |
232 |
|
//them before confirmation has been accepted. |
233 |
|
$this->_form_content->_pre_confirm(); |
234 |
|
} |
235 |
|
|
236 |
|
//call the user defineable FormContent pre_confirm. |
237 |
return $this->_form_content->pre_confirm(); |
return $this->_form_content->pre_confirm(); |
238 |
} |
} |
239 |
|
|
644 |
|
|
645 |
|
|
646 |
/** |
/** |
647 |
|
* Set the onsubmit attribute to the form |
648 |
|
* NOTE: The FormContent child can automatically |
649 |
|
* set this value depending on the FormElement |
650 |
|
* children it contains. |
651 |
|
* |
652 |
|
* @param string |
653 |
|
* @return none |
654 |
|
*/ |
655 |
|
function set_onsubmit($js) { |
656 |
|
$this->_form_attributes["onsubmit"] = $js; |
657 |
|
} |
658 |
|
|
659 |
|
/** |
660 |
|
* Gets the current value of the form tag's |
661 |
|
* onsubmit value |
662 |
|
* |
663 |
|
* @return string |
664 |
|
*/ |
665 |
|
function get_onsubmit() { |
666 |
|
return $this->_form_attributes["onsubmit"]; |
667 |
|
} |
668 |
|
|
669 |
|
|
670 |
|
//************************************// |
671 |
|
//* Some Private methods *// |
672 |
|
//************************************// |
673 |
|
|
674 |
|
/** |
675 |
|
* This method initializes the FormContent |
676 |
|
* during processing. |
677 |
|
* |
678 |
|
* @return none |
679 |
|
*/ |
680 |
|
function _init_form_content() { |
681 |
|
//let the form build the FormElement objects |
682 |
|
//that will be used by the form |
683 |
|
$this->_form_content->form_init_elements(); |
684 |
|
|
685 |
|
//first we need to |
686 |
|
if (!@$_REQUEST[FORM_VISITED]) { |
687 |
|
$this->_form_content->form_init_data(); |
688 |
|
} |
689 |
|
|
690 |
|
//see if the form content has a child of the |
691 |
|
//FEFile element, so we can automatically |
692 |
|
//add the enctype to the form tag attribute |
693 |
|
if ($this->_form_content->_has_file_element) { |
694 |
|
$this->set_form_enctype("multipart/form-data"); |
695 |
|
} |
696 |
|
} |
697 |
|
|
698 |
|
|
699 |
|
/** |
700 |
* this function builds the FORMtag object |
* this function builds the FORMtag object |
701 |
* and its attributes. |
* and its attributes. |
702 |
* |
* |
703 |
* @return FORMtag object. |
* @return FORMtag object. |
704 |
*/ |
*/ |
705 |
function _build_form_tag() { |
function _build_form_tag() { |
706 |
|
//see if we need to add the onsubmit attribute to the form |
707 |
|
//this only needs to happen on the non-confirmation |
708 |
|
//portion of the forms. |
709 |
|
if (!isset($_REQUEST[FORM_VISITED])) { |
710 |
|
if (strlen($this->_form_content->_form_on_submit) > 0) { |
711 |
|
$set = TRUE; |
712 |
|
$this->set_onsubmit( $this->get_onsubmit().$this->_form_content->_form_on_submit ); |
713 |
|
} |
714 |
|
} else { |
715 |
|
//re-rendering the form and it has errors. |
716 |
|
//we need the onsubmit if they have it. |
717 |
|
if ($_REQUEST[FORM_VISITED] && $this->_has_errors) { |
718 |
|
if (strlen($this->_form_content->_form_on_submit) > 0) { |
719 |
|
$set = TRUE; |
720 |
|
$this->set_onsubmit( $this->get_onsubmit().$this->_form_content->_form_on_submit ); |
721 |
|
} |
722 |
|
} |
723 |
|
|
724 |
|
//form has been confirmed lets add it |
725 |
|
//in case we are showing the form again |
726 |
|
if (isset($_REQUEST[FORM_CONFIRM]) && $_REQUEST[FORM_CONFIRM] == 1) { |
727 |
|
if (strlen($this->_form_content->_form_on_submit) > 0) { |
728 |
|
$set = TRUE; |
729 |
|
$this->set_onsubmit( $this->get_onsubmit().$this->_form_content->_form_on_submit ); |
730 |
|
} |
731 |
|
} |
732 |
|
} |
733 |
|
|
734 |
$form_attrs = array(); |
$form_attrs = array(); |
735 |
foreach( $this->_form_attributes as $name => $value) { |
foreach( $this->_form_attributes as $name => $value) { |
736 |
if ($value) { |
if ($value) { |
748 |
function _add_confirm_data() { |
function _add_confirm_data() { |
749 |
$keys = array_keys( $this->_form_content->_elements ); |
$keys = array_keys( $this->_form_content->_elements ); |
750 |
foreach( $keys as $key ) { |
foreach( $keys as $key ) { |
751 |
$element_name = $this->_form_content->_elements[$key]->get_element_name(); |
$this->_form->add($this->_form_content->_elements[$key]->get_confirm_element()); |
|
$values = $this->_form_content->_elements[$key]->get_value(); |
|
|
if (is_array($values)) { |
|
|
foreach($values as $value) { |
|
|
$this->_form->add( form_hidden($element_name, $value) ); |
|
|
} |
|
|
} else { |
|
|
$this->_form->add( form_hidden($element_name, $values) ); |
|
|
|
|
|
} |
|
752 |
} |
} |
753 |
|
|
754 |
$keys = array_keys( $this->_form_content->_hidden_elements ); |
$keys = array_keys( $this->_form_content->_hidden_elements ); |
755 |
foreach( $keys as $key ) { |
foreach( $keys as $key ) { |
756 |
$this->_form->add( $this->_form_content->_hidden_elements[$key]->get_element() ); |
$this->_form->add( $this->_form_content->_hidden_elements[$key]->get_confirm_element() ); |
757 |
} |
} |
758 |
} |
} |
759 |
|
|