Jump to content

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


Orkun
 Share

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");
              

            }

        }

Link to comment
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
Link to comment
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

Link to comment
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
 Share

×
×
  • Create New...