mercredi 5 juillet 2017

How to get a value from checkbox for a multiple choices

I have:

field 1:select for one choice, it concerns the years.

field 2: checkbox for multiple choice, it concerns the articles.

When I do not select any choice in field 2 I should get ALL value, here it works well my code. But when I choose one or more item I don't get the best values.

My code is the following:

  public function prepareQuery() {


        //echo "CHEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK";
        //var_dump($this->_lru);
        if (!empty($this->_lru)) {
            if(is_array($this->_lru) or ($this->_lru instanceof Traversable)) {
                if(count($this->_lru)<1) {
                    $this->_lru = null;
                } elseif(count($this->_lru)==1) {
                    if ($this->_lru[0] == 'ALL' || $this->_lru[0] == 'all') {
                        $this->_lru = null;
                    }                   
                }

            }  else {
                if ($this->_lru == 'ALL' || $this->_lru == 'all') {
                    $this->_lru = null;
                }
            }
        } else {
        $this->_lru = null;
        }
 if ($this->_lru !== null) {
            $this->rechLRU();
        }

I want to add a test for this case when I choose one or more choice. I hope I was clear in my question because of the case, not hard but a little complicated.




Aucun commentaire:

Enregistrer un commentaire