@JonoB,
Your models can have several callbacks to interact with internal Gas lifecycle. Look at hooks point callbacks, available points are :
_before_check() : run before validate your input (if you set your fields rule in _init function, and you passing TRUE within save() method).
_after_check() : run after validate your input.
_before_save() : run before INSERT or UPDATE operation.
_after_save() : run after above operation.
_before_delete() : run before DELETE operation.
_after_delete() : run after DELETE operation.
In above case, you may want to use _before_check or _before_save callback, depend on how you want to doing it.
So, suppose you have some post data like this one :
$_POST = array(
'name' => 'Mr. Foo',
'email' => 'foo@bar.com',
'username' => 'foo',
'somefields' => 'Lorem',
'otherfields' => 'Ipsum',
);
// and you try to save it
$new_user = Gas::factory('user')->fill($_POST);
$new_user->save(TRUE);
Then in your Gas model, if you want to only save name, email and username, you can executed your own filtering method on _before_save() callback, mean you want to validate all the data, but only several of it will be saved/updated.
// within your Gas model, suppose you set your own properties
public $attributes = array('name', 'email', 'username');
//...
//...
function _before_save()
{
// Here you can see all populated data, dont try to check $_POST here.
// Gas has its own mechanism, so overide/change/modify $_POST will not affect anything
$old_data = $this->filled_fields();
// Here you can implement your own filtering method
$new_data = $this->filter_attributes($old_data);
// to overide all set data, use set_fields() method
$this->set_fields($new_data);
return $this;
}
This mean you can also modified some (or all) of it, or adding some common fields (like timestamps) before save/update data.