Beispiel #1
0
 function getCellTemplate($column, $fieldId, $value = null, $permissions = array('view' => 1, 'edit' => 1))
 {
     $element = df_clone($this->elements[$column]);
     $element->setName($this->name . '[' . $this->next_row_id . '][' . $column . ']');
     $element->updateAttributes(array('id' => $column . '_' . $fieldId, 'onchange' => (($this->addNew or $this->addExisting) ? 'dataGridFieldFunctions.addRowOnChange(this);' : '') . $element->getAttribute('onchange'), 'style' => 'width:100%;' . $element->getAttribute('style')));
     if ($this->isFrozen() or !Dataface_PermissionsTool::checkPermission('edit', $permissions)) {
         $element->freeze();
     } else {
         $element->unfreeze();
     }
     if (isset($value)) {
         $element->setValue($value);
     }
     return $element->toHtml();
 }
Beispiel #2
0
 function pushValue(&$record, &$field, &$form, &$element, &$metaValues)
 {
     $val = $element->getValue();
     $filters = array();
     $subfactory = new HTML_QuickForm();
     foreach ($element->getColumnIds() as $colname) {
         $colFieldDef = $element->getColumnFieldDef($colname);
         $columnElement = df_clone($element->getColumnElement($colname));
         // We need to be a bit more refined on this one.  We need to take
         // into account the context being that we are in a relationship.
         $dummyRecord = new Dataface_Record($colFieldDef['tablename'], array());
         //$colFieldDef = $colTable->getField($column);
         $filter = new Dataface_FormTool_grid_filter($dummyRecord, $colFieldDef, $subfactory, $columnElement, false);
         $filters[$colname] = $filter;
         unset($colFieldDef);
         unset($dummyRecord);
         unset($colFieldDef);
         unset($columnElement);
     }
     $last_id = -1;
     foreach ($val as $key => $row) {
         if (is_array($row) and isset($row['__id__']) and $row['__id__'] == 'new') {
             $last_id = $key;
         }
         if (is_array($row)) {
             foreach ($row as $colname => $colval) {
                 if (isset($filters[$colname])) {
                     $val[$key][$colname] = $filters[$colname]->pushValue($colval);
                 }
             }
         }
     }
     if ($last_id != -1) {
         unset($val[$last_id]);
     }
     return $val;
 }