Jump to content
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By ngrmm
      I have a page with a table. Each table row has a page-reference field and a checkbox.
      The Page sends emails to all users (page-refrence->email-field) and change the value of the checkbox in a row to 1.
      It works with this:
      <?php // event ID fron url query $eventID = $input->get('eventID','int'); // get event-page $event = $pages->get($eventID); // config $fromEmail = $event->event_mail_from; $fromName = $event->event_mail_from_name; $emailSubject = $event->event_subject; // email html body ob_start(); include('./_inc/emailbody.inc'); $emailBody = ob_get_clean(); // make event-page editable $event->of(false); // loop through table and send out emails foreach($event->event_clients_list as $event_table_row) { // get client page $clientPage = $event_table_row->client_name; // get client email $clientEmail = $clientPage->email; // if client isn't invited yet (checkbox not checked) if($event_table_row->client_invited == '') { // send email $m = new WireMail(); $m->to($clientEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); // mark client as invited $event_table_row->client_invited = 1; $event->save('event_clients_list'); } } ?> But i have to use a variable in my emailbody.inc which i'm able to get in the table-loop.
      So i do the including of the body inside my loop. But this doesn't work anymore. Page sends out the emails but is unable to change the value of the checkbox.
      I get no errors!
      I'm using ProTable
      <?php // event ID fron url query $eventID = $input->get('eventID','int'); // get event-page $event = $pages->get($eventID); // config $fromEmail = $event->event_mail_from; $fromName = $event->event_mail_from_name; $emailSubject = $event->event_subject; // loop through table and send out emails foreach($event->event_clients_list as $event_table_row) { // get client page $clientPage = $event_table_row->client_name; // get client email $clientEmail = $clientPage->email; // email html body ob_start(); include('./_inc/emailbody.inc'); $emailBody = ob_get_clean(); // make event-page editable $event->of(false); // if client isn't invited yet (checkbox not checked) if($event_table_row->client_invited == '') { // send email $m = new WireMail(); $m->to($clientEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); // mark client as invited $event_table_row->client_invited = 1; $event->save('event_clients_list'); } } ?>  
    • By Vigilante
      In general, is there an easy way to know which method should be used to access the API?
      For example, when _ini.php is used in the theme, it would seem you have to use wire()->addHookBefore(...). But on other sites where they used ready.php, I've seen it go straight to just doing $this->addHookAfter() even though there is no class or namespace set up in the ready.php file.
      So how do I know when I can do $this, or $wire, or wire() to access things? And any other variables I'm not aware of.
      Thanks!
    • By VeiJari
      Hello forum,
      This is really a weird one, because front end editing works in a earlier website we did to a customer. 
      When I check the source code for current website it does initiate front end edit: 
      <span id=pw-edit-1 class='pw-edit pw-edit-InputfieldPageTitle' data-name=title data-page=1021 data-lang='1017' style='position:relative'><span class=pw-edit-orig>Tekijät</span><span class=pw-edit-copy id=pw-editor-title-1021 style='display:none;-webkit-user-select:text;user- select:text;' contenteditable>Tekijät</span></span>  But when I double click nothing happens (yes I'm 100% sure I'm superuser and logged in)
      I also tried to apply the front end with other methods than:
      $page->edit('title'); But didn't work either.
      We are using jquery 2.2.4, so it should not be a problem.
      Is this a bug related to current master or something else?
      Someone else having this problem as well?
    • By Moritz Both
      Greetings,
      when I give users the user-admin-* permission to administer users who have a certain role, they can indeed see and edit those users. However the filter / column panel does not show in the admin interface. How can I enable the filter functionality for user-admin-* members?
      ProcessWire 3.0.123
      Moritz
    • By MaierGrem
      Question to professionals)
      I use the "Page Reference" field (name = categories, types = multiple, asm-select) and checkbox field (name = notify_user).
      When editing the page, I need to check if:
      - (categories) values has changed (deselected one or more current pages), make (notify_user) required.
      - (categories) values has changed (selected one or more new pages), make (notify_user) required.
      - (categories) values don't change, then the (notify_user) is not required.
      I tried to make a condition, required if:
      1. "categories!=1020|1490" - does not work.
      2. "categories!=1020|1490, categories.count != 2" - does not work.
      3. "categories%=1020|1490 - js error.
      Please advise how best to solve this problem.
×
×
  • Create New...