Example #1
0
 /**
  * Generates a widget to show a html grid filter
  *
  * @param \Engine\Crud\Form $form
  * @return string
  */
 public static function _(Form $crudForm)
 {
     $crudForm->initForm();
     $form = $crudForm->getForm();
     $code = '<form method="' . $form->getMethod() . '" action="' . $form->getAction() . '" class="form-horizontal">';
     $code .= "\n            <fieldset>\n            <legend>" . $crudForm->getTitle() . "</legend>";
     return $code;
 }
Example #2
0
 /**
  * Return field save data
  * 
  * @return array|bool
  */
 public function getSaveData()
 {
     if ($this->_notSave) {
         return false;
     }
     if ($this->_notEdit && $this->_form->getId()) {
         return false;
     }
     return ['key' => $this->getName(), 'value' => $this->getValue()];
 }
Example #3
0
 /**
  * Update column in rows by array of primary key values.
  * 
  * @param string $column
  * @param array|string $ids
  * @param array $value
  * @return bool|array
  */
 public function bulkUpdate($ids, array $data)
 {
     if (!is_array($ids)) {
         $ids = trim($ids);
         if ($ids == "") {
             return false;
         }
         $ids = [$ids];
     }
     if (count($ids) == 0) {
         return false;
     }
     $updateData = [];
     foreach ($data as $key => $value) {
         $column = isset($this->_columns[$key]) ? $this->_columns[$key] : $this->getColumnByName($key);
         if ($column === false) {
             return false;
         }
         $name = $column->getName();
         if (null !== $this->_form) {
             if (!($field = $this->_form->getFieldByKey($key))) {
                 $field = $this->_form->getFieldByName($name);
             }
             $field->setValue($value);
             $saveData = $field->getSaveData();
             $updateData[$saveData['key']] = $saveData['value'];
         } else {
             $updateData[$name] = $value;
         }
     }
     return $this->_container->update($ids, $updateData);
 }