Example #1
0
 /**
  * @todo secure code
  * change_field
  * quick_edit
  * POST: field: $this.attr('name'), value: $this.val()
  */
 function action_change_field()
 {
     $field = $this->request->post('field');
     $value = $this->request->post('value');
     if ($this->request->method == 'GET') {
         $this->_ajax_answer(false, i18n::T('Method not available'));
         return;
     }
     if (!$field || !$this->collection->get_field($field)) {
         $this->_ajax_answer(false, i18n::T('Field change failed'));
         return;
     }
     if (is_callable(array($this, 'action_change_field_before'))) {
         if (false === $this->action_change_field_before($field, $value)) {
             return false;
         }
     }
     $_item = $this->_load_id();
     $_item->set_data($field, $value);
     $_item->update_fields($field);
     if ($this->in_ajax()) {
         $this->_ajax_answer(true, i18n::T('Field modified'));
     }
     $this->disable_render(true);
     if (is_callable(array($this, 'action_change_field_after'))) {
         $this->action_change_field_after($field, $value);
     }
 }