Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php namespace Craft;
  2.  
  3. class SamplePlugin extends BasePlugin {
  4.  
  5. function getName() { ... }
  6. function getVersion() { ... }
  7. function getDeveloper() { ... }
  8. function getDeveloperUrl() { ... }
  9.  
  10. public function getSettingsHtml()
  11. {
  12. return craft()->templates->render('sample/settings', [
  13. 'settings' => $this->getSettings()
  14. ]);
  15. }
  16.  
  17. public function prepSettings($settings)
  18. {
  19. // I'm currently doing my 'custom' validation here. But if
  20. // there's an error, how do I display errors on the settings page?
  21.  
  22. return $settings;
  23. }
  24.  
  25. public function rules()
  26. {
  27. // Tried this, but since SamplePlugin isn't a Model, it does nothing.
  28. }
  29.  
  30. protected function defineSettings()
  31. {
  32. return [
  33. 'mySetting' => [
  34. AttributeType::String,
  35. 'required' => true,
  36. // Can custom validation rules be set here?
  37. ]
  38. ];
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement