Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to modify form data in the $form array before processing?


Go to End


2749 Views

Avatar
Nexus Rex

Community Member, 8 Posts

13 March 2009 at 5:51am

I have a function that is processing a form.

I am easily able to access the submitted data in the $data array to modify my element AocID from a string like "AOC-1003" to an int "1003", but I can't figure out how to do the same to the element AocID in the $form array.

THIS WORKS:

	function processOrder($data, $form) {
		// Change the AocID into an integer if it's not already
		if($data[AocID]) {
			if(is_numeric($data[AocID])) {
				$data[AocID] = $data[AocID];
			} else {
				$data[AocID] = ereg_replace( '[^0-9]+', '', $data[AocID] );
			}
		}
		...

Q: HOW DO I ACCESS "AocID" IN THE $form ARRAY?