Orkun

Adding more Filters/Conditions to Form(created by the api(InputfieldForm etc...))

Recommended Posts

How can I achieve something like this where I can add more Conditions or delete them:

post-3125-0-62937000-1452611085_thumb.pn

Inside this Form where I create Segments for a Mailchimp Account

post-3125-0-01965600-1452611081_thumb.pn

Form processing looks like this:

if($this->input->post->createSegment) {

            $form->segmentnameParam->required = 1;
            $form->fieldParam->required = 1;
            $form->operatorParam->required = 1;
            $form->searchParam->required = 1;
            $form->match->required = 1;

            $form->processInput($this->input->post);

            if(!$form->getErrors()) {
                $segment_name = $this->sanitizer->text($form->get("segmentnameParam")->value);
                $field_name = $form->get("fieldParam")->value;
                $operator = $form->get("operatorParam")->value;
                $search_value = $this->sanitizer->text($form->get("searchParam")->value);
                $match = $this->sanitizer->text($form->get("match")->value);

              
                $res = $this->mailchimp->call("/lists/segment-add", array(
                "id" => $list_id,
                "opts" => array(
                    "type" => "saved", 
                    "name" => $segment_name,
                    "segment_opts" => array(
                        "match" => $match, 
                        "conditions" => array(
                            array(
                                "field" => $field_name, 
                                "op" => "eq",
                                "value" => $search_value,
                            )
                        )
                    )
                )
                ));

               if($res){
                  $this->message(sprintf($this->_("Created new Segment called: '%s'"), $segmentnameParam));
               }

               $this->session->redirect("../edit/?id=$list_id");
              

            }

        }

Share this post


Link to post
Share on other sites

InputfieldSelector is build to be a GUI for building page selector strings and is therefore quite specialized to that job. But you could always take a look into the files of the module and see if you can reconstruct the parts you need (e.g. all the ajax things are probably not needed).

  • Like 1

Share this post


Link to post
Share on other sites

InputfieldSelector is build to be a GUI for building page selector strings and is therefore quite specialized to that job. But you could always take a look into the files of the module and see if you can reconstruct the parts you need (e.g. all the ajax things are probably not needed).

Do you mean the ProcessPageLister.module File? I looked in that file, but couldn't figure out which parts I need. Are there other Files where it is "clearer" which parts i need to achieve that "add Filter/Condition" functionality. Isn't that handled also with Ajax/Jquery ?

Greetings Orkun

Share this post


Link to post
Share on other sites

I'm talking about InputfieldSelector.module. Also AJAX is only needed if the filters do contain something dynamically changing, which I suspected to not be the case, but you're certainly right, that you'd need jquery or at least javascript. 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Harmen
      I want to add a few pages to an AsmSelect Page field inside a repeater using the following code:
      $trialsPage = wire("pages")->get(28422); // Get the page $trialsPage->of(false); $newTrial = $ordersPage->trial_repeater_orders->getNewItem(); // Add item to repeater foreach ($selectedProducts as $selectedProduct){ $productPage = $pages->get("template=product, reference=$selectedProduct"); $newTrial->trial_selected_products->add($productPage); } $newTrial->save(); $trialsPage->save(); However, when I check the page where the field is located it doesn't have the new values as expected. The selected pages exist, the field is in the right location, made sure that the output formatting is turned off: $page->of(false); But it still doesn't work with a variable. No matter what I try, it doesn't work.
      It only works when I replace $selectedProduct with a hardcoded string. Am I doing something wrong here?
    • By louisstephens
      So I have been diving into hooks lately, and I am enjoying them thus far. However, I guess I am a bit stumped on how to achieve what I want too. I am trying to set up a hook that would create a new child page when the parent page is saved. However, when you save the parent page a second time, I just need to update the child page without creating multiple child pages. What would be the best way to go about this?
      So after rereading my post, I believe it is a bit vague so I will try to explain more. 
      The Goal:
      Create a page with a template "one". Once the page is created/saved => create a new child page with the template of "two" If the parent is saved anytime after, do nothing to the child page (limit the parent page to one child page) The parent page is really just being used to output content, whereas the child page is being used to pull out the some fields from the parent to be used elsewhere. I might have made this too complicated in my head.
    • By Demo
      Hi,
      I'm looking for a developer for a quick project. Developer would be responsible to create a new form on exiting process wire site which on submit would send data to sales force. We already have the HTML code for the form and action/REST API build. 
      Thank you
      Rajesh
    • By Demo
      Hi,
      I'm a newbie to Process wire. I'm trying to pass the form values to a different URL (i.e to sales force). We have a RestAPI to do a post method with URL Prams. when we tested the rest API it works with static values. So, i select the the option called submit to another URL in actions tab in my form. 
      So now the issue is how can i pass the field values dynamically to the REST API prams on form submit?
       
      If their is any easy way to submit form details to sales force please advice.
       
      Thanks in advance!! 

    • By Peter Knight
      Is there a way to make JPGs progressive by default via the API?
      I've added the following to my site/config.php file but user-uploaded images are often displayed as non progressive.
      $config->imageSizerOptions = array( 'upscaling' => true, // upscale if necessary to reach target size? 'cropping' => true, // crop if necessary to reach target size? 'autoRotation' => true, // automatically correct orientation? 'interlace' => true, // use interlaced JPEGs by default? (recommended) 'sharpening' => 'soft', // sharpening: none | soft | medium | strong 'quality' => 95, // quality: 1-100 where higher is better but bigger 'hidpiQuality' => 60, // Same as above quality setting, but specific to hidpi images 'defaultGamma' => 0.5, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0) ); Thanks