Answers.Body: <p>So I found the answer i was looking for.</p>
  
  <p>It looks like if you add a prepValue function to your fieldtypes class it can perform any action you want on the value from your custom field before returning it to the template</p>
  
  <p>Looks something like this</p>
  
  <pre><code>class PLUGINNAME_FIELDNAMEFieldType extends BaseFieldType
  {
      public function getName()
      {
          return Craft::t('My Field\'s Name');
      }
  
  ...
      public function prepValue($value)
      {
        // do stuff with value here like create a model, or just some conversion
        $newValue = $value." &lt;strong&gt;it works!&lt;/strong&gt;";
  
        // newValue is whats returned to the template when you access via entry.customFieldName
        return TemplateHelper::getRaw($newValue);
  
        // Note: TemplateHelper::getRaw isnt required it just included cause the newValue includes html that i want to render on the page, default behavior is to escape all html
  
      }
  
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T23:39:40.613Z
Answers.LastActivityDate: 2014-08-13T23:39:40.613Z
Answers.UserDisplayName: Keith Mancuso
Answers.Body: <p>Run your HTML string through <code>getRaw</code> before sending it back to the template...</p>
  
  <pre><code>return TemplateHelper::getRaw($output);
  </code></pre>
  
  <p>This will basically "pre-raw" your HTML string.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T16:43:51.817Z
Answers.Text: nice! that takes care of that one. any thoughts on returning the html directly throught the field variable?  is that even possible?
Answers.UserDisplayName: Keith Mancuso
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T16:42:01.020Z
Answers.LastActivityDate: 2014-08-13T16:42:01.020Z
Answers.UserDisplayName: Lindsey D
Body: <p>Is it possible to control what gets output in the template a custom fieldtype?</p>
  
  <p>For example im working on a eventbrite plugin and it saves the id in the database but I want the field in the template to return a fully formatted register button.</p>
  
  <p>Right now im doing this with a craft variable that i'm passing the id and returns the html for the button into but feels like there might be a simpler way?</p>
  
  <hr>
  
  <p>Related to that right now i have to add | raw to the variable output</p>
  
  <p>so its </p>
  
  <pre><code>{{ craft.eventBrite.registerButton(entry.eventbriteId) | raw }}
  </code></pre>
  
  <p>is there a way to prevent the escaping of whats being returned without the extra filter in the template?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-13T17:00:59.350Z
Comments.Text: I'm confused about the first part of your question... You want your field to automatically determine if an entry has already been loaded (ie: dynamic entry URLs)? It looks to me like you're already doing it right... How else would your `registerButton` know which `eventbriteId` it was working with?
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-13T18:55:57.153Z
Comments.Text: I guess i mean instead of making the customfield just be the id that the logic for the button could be in the field and output would come just by accessing the custom field... more like what dukt is doing wiht the video plugin for example.. https://dukt.net/craft/videos/docs/video-fields
Comments.UserDisplayName: Keith Mancuso
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-08-13T18:59:40.467Z
Comments.Text: ahh looks like its the prepValue function in the fieldtype is what im looking for, lets you change the value saved in the database into whatever you want like an object with sub values
Comments.UserDisplayName: Keith Mancuso
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-15T07:54:15.187Z
Comments.Text: I came across this question while searching for Event Brite plugins for CraftCMS...
  
  Will your Event Brite plugin be available for commercial or public use?
Comments.UserDisplayName: Sean Delaney
Tags: <plugin-development><custom-fieldtype>
Title: How do you customize what value a Custom FieldType returns to a template
ThreadText: # How do you customize what value a Custom FieldType returns to a template
  
  (Asked by: username_0 on 2014-08-13)
  
  Is it possible to control what gets output in the template a custom fieldtype?
  
  For example im working on a eventbrite plugin and it saves the id in the database but I want the field in the template to return a fully formatted register button.
  
  Right now im doing this with a craft variable that i'm passing the id and returns the html for the button into but feels like there might be a simpler way?
  
  ---
  
  Related to that right now i have to add | raw to the variable output
  
  so its
  
  ```
  {{ craft.eventBrite.registerButton(entry.eventbriteId) | raw }}
  
  ```
  
  is there a way to prevent the escaping of whats being returned without the extra filter in the template?
  
  **Tags:** plugin-development, custom-fieldtype
  
  > **Comments:**
  > **username_1**: I'm confused about the first part of your question... You want your field to automatically determine if an entry has already been loaded (ie: dynamic entry URLs)? It looks to me like you're already doing it right... How else would your `registerButton` know which `eventbriteId` it was working with?  
  > **username_0**: I guess i mean instead of making the customfield just be the id that the logic for the button could be in the field and output would come just by accessing the custom field... more like what dukt is doing wiht the video plugin for example.. https://dukt.net/craft/videos/docs/video-fields  
  > **username_0**: ahh looks like its the prepValue function in the fieldtype is what im looking for, lets you change the value saved in the database into whatever you want like an object with sub values  
  > **username_2**: I came across this question while searching for Event Brite plugins for CraftCMS...  Will your Event Brite plugin be available for commercial or public use?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2014-08-13. Score: 2 | Accepted answer
  
  So I found the answer i was looking for.
  
  It looks like if you add a prepValue function to your fieldtypes class it can perform any action you want on the value from your custom field before returning it to the template
  
  Looks something like this
  
  ```
  class PLUGINNAME_FIELDNAMEFieldType extends BaseFieldType
  {
      public function getName()
      {
          return Craft::t('My Field\'s Name');
      }
  
  ...
      public function prepValue($value)
      {
        // do stuff with value here like create a model, or just some conversion
        $newValue = $value." <strong>it works!</strong>";
  
        // newValue is whats returned to the template when you access via entry.customFieldName
        return TemplateHelper::getRaw($newValue);
  
        // Note: TemplateHelper::getRaw isnt required it just included cause the newValue includes html that i want to render on the page, default behavior is to escape all html
  
      }
  
  }
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2014-08-13. Score: 4
  
  Run your HTML string through `getRaw` before sending it back to the template...
  
  ```
  return TemplateHelper::getRaw($output);
  
  ```
  
  This will basically "pre-raw" your HTML string.
  
  > **Comments:**
  > **username_0**: nice! that takes care of that one. any thoughts on returning the html directly throught the field variable?  is that even possible?  
  
  ---
  
  