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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

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

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


Go to End


2323 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?