Update attributegroup.php for better attribute setting.

Update attributegroup.php for better attribute settings. More to come. Give me ideas or send pull requests.