public static function save(\Validation $val, $posted_values) { $field_names = \Form_Util::get_field_names($val); foreach ($field_names as $name) { $site_config_obj = \Model_SiteConfig::get4name($name); if ($site_config_obj && $site_config_obj->value == $posted_values[$name]) { continue; } if (!$site_config_obj) { $site_config_obj = \Model_SiteConfig::forge(); } $site_config_obj->name = $name; $site_config_obj->value = $posted_values[$name]; $site_config_obj->save(); } }
public static function save($member_id, Validation $val, $posted_values) { $field_names = Form_Util::get_field_names($val); foreach ($field_names as $name) { $member_config = Model_MemberConfig::get_one4member_id_and_name($member_id, $name); if ($member_config && $member_config->value == $posted_values[$name]) { continue; } if (!$member_config) { $member_config = Model_MemberConfig::forge(); } $member_config->member_id = $member_id; $member_config->name = $name; $member_config->value = $posted_values[$name]; $member_config->save(); } }