/** * * @return Objectmanager_Models_Object */ public function loadFieldsForObject() { $where = array(); $order = array(array('order_index', 'DESC')); // get all fields for object $where[] = array('AND', 'id_sys_object', '=', intval($this->id)); $sys_field = new Crud_Models_Field(); $sys_field_list = $sys_field->search($where, $order); foreach ($sys_field_list as $sys_field) { $this->sys_field_list[$sys_field->field_name] = $sys_field; } return $this; }
public function modify($sys_object_id) { $sys_object = new Crud_Models_Object(); $sys_object->load(intval($sys_object_id)); $sys_object->loadFieldsForObject(); if (isset($_POST) && !empty($_POST)) { $field_list = array(); $sys_object->table_title = $_POST['table_title']; $sys_object->group_name = $_POST['group_name']; $sys_object->custom_crud_class = $_POST['custom_crud_class']; $sys_object->is_system = isset($_POST['is_system']) && $_POST['is_system'] == 1 ? 1 : 0; $sys_object->save(); foreach ($_POST['field_title'] as $field_id => $field_title) { $properties = array(); foreach ($_POST as $key => $value) { if (preg_match('/^control-properties-/', $key) && isset($value[$field_id])) { $property_key = str_replace('control-properties-', '', $key); $properties[$property_key] = $value[$field_id]; } } $field = new Crud_Models_Field(); $field->load($field_id); if ($field->isEmpty()) { $field->id_sys_object = $sys_object->id; } $field->id_sys_control = isset($_POST['id_sys_control'][$field_id]) ? intval($_POST['id_sys_control'][$field_id]) : 0; $field->ids_sys_validator = isset($_POST['ids_sys_validator'][$field_id]) ? implode(',', $_POST['ids_sys_validator'][$field_id]) : ''; $field->field_title = $field_title; $field->field_description = $_POST['field_description'][$field_id]; $field->order_index = $_POST['order_index'][$field_id]; $field->is_hidden = isset($_POST['is_hidden'][$field_id]) ? intval($_POST['is_hidden'][$field_id]) : 0; $field->is_identification = isset($_POST['is_identification'][$field_id]) ? intval($_POST['is_identification'][$field_id]) : 0; $field->sys_control_properties = !empty($properties) ? json_encode($properties) : ''; $field->save(); } foreach ($_POST['id_sys_object_child'] as $relation_id => $id_sys_object_child) { $subform = new Crud_Models_Subform(); $subform->load($relation_id); if (!$subform->isEmpty()) { if ($subform->id_sys_object_parent != $sys_object->id) { $subform = new Crud_Models_Subform(); } } if (isset($_POST['delete']) && isset($_POST['delete'][$relation_id]) && $_POST['delete'][$relation_id] == 1) { $subform->delete(); } else { $where = array(); $where[] = array('AND', 'id_sys_object', '=', $id_sys_object_child); $where[] = array('AND', 'field_name', '=', $_POST['sys_field_title'][$relation_id]); $field = new Crud_Models_Field(); $fields = $field->search($where); if (empty($fields)) { continue; } $field = $fields[0]; $subform->id_sys_object_parent = $sys_object->id; $subform->id_sys_object_child = $id_sys_object_child; $subform->id_sys_field = $field->id; $subform->title = $_POST['title'][$relation_id]; $subform->save(); } } } header('location: ' . SITE_ROOT_URI . '/crud/objects/maplist/'); exit; }
<?php // load maped objects $where = array(); $order = array(); //$where[] = array('AND', 'id', '!=', $parent_sys_object_id); $order[] = array('table_name', 'ASC'); $maped_object = new Crud_Models_Object(); $maped_objects = $maped_object->search($where, $order); $where = array(); $where[] = array('AND', 'id_sys_object', '=', $field->id_sys_object); $where[] = array('AND', 'id', '!=', $field->id); $sys_field = new Crud_Models_Field(); $sys_fields = $sys_field->search($where); ?> <div class="form-group"> <label>Table</label> <div class="ocp-select"> <select class="form-control" name="control-properties-table_name[<?php echo $field->id; ?> ]"> <option value=""></option> <?php foreach ($maped_objects as $maped_object) { ?> <option <?php echo isset($properties->table_name) && $properties->table_name == $maped_object->table_name ? 'selected="selected"' : ''; ?> value="<?php echo $maped_object->table_name;