We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Bind to Event Post | Forum

Marcus
Marcus Aug 20 '19

What is the name of the event that hold form post data?

if ( OW::getRequest()->isPost()


some like this maybe: OW_EventManager::ON_FORM_RENDER

Thanks

The Forum post is edited by Marcus Aug 20 '19
dave Leader
dave Aug 20 '19
Ill have to check, im not sure if there is one or not because you form submission post is sent when you press send form so if you want to grab it then just follow below.    



But basically here is how the form works. 

 
the html file sets the fields and the form namethen the php file you have   


$form = new Form('formname');  


then in the php file you set the fields to what you want 


example:  you can call it whatever you want, such as  $MyFormData         


         $MyFormData = new TextField('fieldname');

         $MyFormData->setLabel($language->text('pluginname', 'lang key here'));

         $MyFormData->setRequired(); 

         $MyFormData->addAttribute('size','10');

         $MyFormData->addAttribute('maxlength','30');

         $form->addElement($MyFormData); 

then once you have all your fields assigned then you just add the form
$this->addForm($form);  

Then when you submit the form it looks for the request that is a post request which is secure (there is post and get)  and you also run it through the validator


  if( OW::getRequest()->isPost() )         

  {           

      if ( $form->isValid($_POST) )             

       {

    then to get the values of the form  
    $values = $form->getValues();

     
example of one value would be 


     $vidtitle = $values['vidtitle'];  whatever you called your fieldname


if you want to view the whole array of the form you can do 


echo "<pre>";

print_r($values);

exit;

does that help?

The Forum post is edited by dave Aug 20 '19
dave Leader
dave Aug 20 '19
If you want to trap an event like before profile save, or after pic upload, those are listed in the eventhandler file in the core, there are a bunch of them..  
Marcus
Marcus Aug 20 '19
Thanks Dave for your code. Let me explain let say there is a page with a form in it now the code you posted is in the controller OK. Now there is no event triggered when that form gets submitted. I thought there is a way to intercept $_post parameters from outside of the controller like from the plug-in.

Basically I'm trying to check forum reply message. Currently there is no before save post event triggered so I can't prossess the text before it gets saved 
The Forum post is edited by Marcus Aug 20 '19
dave Leader
dave Aug 20 '19
OH ok now i get what you need...  let me do some poking around and see what i find... 
dave Leader
dave Aug 20 '19
I did find these in the blog classes listener so it might also work for forum.  


        OW::getEventManager()->bind(PostService::EVENT_AFTER_ADD, array($this, "onAfterPostAdd"));


        OW::getEventManager()->bind(PostService::EVENT_AFTER_EDIT, array($this, "onAfterPostEdit"));


also there is a save event in the blogs controllers save.php file 


                OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_ADD, array(


so you might be able to work that same logic using the postservice into your plugin or find same event in forum 



The Forum post is edited by dave Aug 20 '19
Marcus
Marcus Aug 20 '19
Great Dave it's already too late here I'll try it out tomorrow. Really appreciate your support
amritajain
amritajain Oct 6 '22

I'm interested in your article that you published on this website, Dehradun Escort Service so please keep sharing insightful facts.

tinmach
tinmach Dec 11 '22
To put it simply, I want to verify a forum post of response. Unfortunately, I am unable to process the content prior to saving since no pre-save post event is currently being fired.  geometry dash subzero