コード例 #1
0
 /**
  * Set strainer as a Boolean
  *
  * @param null $callable
  * @param array $attr
  * @return $this
  */
 public function setStrainerBoolean($callable = null, $attr = [])
 {
     // if callable is a string , it's a field
     if (is_string($callable) || $callable instanceof Expression) {
         $field = $callable;
         $callable = null;
     }
     // create the strainer
     $strainer = new Boolean($this, $callable, $attr);
     //if a fields is set, we configure the strainer
     if (isset($field)) {
         $strainer->setField($field);
     }
     return $this->setStrainer($strainer);
 }
コード例 #2
0
ファイル: Bootstrap.php プロジェクト: frenchfrogs/framework
 /**
  * Render strainer for a select element
  *
  * @param \FrenchFrogs\Table\Column\Strainer\Select $strainer
  * @return string
  */
 public function strainerBoolean(Column\Strainer\Boolean $strainer)
 {
     $element = $strainer->getElement();
     $element->addStyle('width', '100%');
     $element->addClass(Style::FORM_ELEMENT_CONTROL);
     $options = '';
     if ($element->hasPlaceholder()) {
         $options .= html('option', ['value' => null], $element->getPlaceholder());
     }
     foreach ($element->getOptions() as $value => $label) {
         $attr = ['value' => $value];
         if ($element->hasValue() && in_array($value, $element->getValue())) {
             $attr['selected'] = 'selected';
         }
         $options .= html('option', $attr, $label);
     }
     return html('select', $element->getAttributes(), $options);
 }