I don't know if this code is great, but the most important is that you can see that the command to fetch the template inside the callback is $view->createTemplateObject. Everything before is just some arrays and variables management. They are coming from the models, which are used to get datas from the database and must not mix with the above code. Check this comand:
If you also want to add your own validation (especially if the input data-type won't match the type expected by DataWriter), since XenForo doesn't allow you to set callbacks in the StyleProperty definition (yet), you will also have to XFCP the XenForo_Model_StyleProperty::saveStylePropertiesInStyleFromInput method.