Jump to:

1971 Posts in 1275 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » How to modify form data in the $form array before processing?

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

Page: 1
Go to End
Author Topic: 1753 Views
  • Nexus Rex
    Avatar
    Community Member
    8 Posts

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

    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?

    1753 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.