Answers.Body: <p>What about modifying the option list itself? So pick a hook that fires whenever the new mailing page is loaded (hook pageRun or something) and use the api to check if the current user's email is an option in that list. If not, add it</p>
  
  <p>That gets you halfway there... not sure about setting it as the default. I suppose if you made it the default every time the hook fires, then it would temporarily be the default for whoever is composing a mailing.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-19T20:16:22.350Z
Answers.Text: per my observation 3 above, there's no clear way to target the mailing form via pageRun(). the object passed to the hook has elements generic to all angular pages -- I don't see any way to filter by the mailing page.
Answers.UserDisplayName: lcdservices
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-19T15:34:17.487Z
Answers.LastActivityDate: 2016-12-19T15:34:17.487Z
Answers.UserDisplayName: Coleman
Body: <p>I'm wrestling with where and how to best make modifications to the CiviMail new mailing form, built with Angular. There are several other questions addressing this in part, but none address my needs completely.</p>
  
  <p>The customization is pretty simple: include the logged in user's email as an option in the From Address selector and set it as the default.</p>
  
  <p>What I've found is that:</p>
  
  <p>1) I can't simply modify the from address list using the optionValues() hook. There are some oddities with from_email_addresses passed to that hook -- not all of the values are passed for modification. And because the select2 widget in the angular form is set to filter on is_active, any values I add via the hook are ignored (the hook only let's me work with the basic option list; I have no access to other record metadata).</p>
  
  <p>2) Even if I use a php override of the CRM/Mailing/Info.php file and alter the from address values passed to angular, the default value is being set in some mystery way that I've not been able to find. Altering the is_default value and weight so that my desired option is the default has no impact.</p>
  
  <p>3) In general, it seems very difficult to target angular forms via a hook in order to inject js. Maybe I'm missing something obvious, but the pageRun() hook doesn't seem to give me enough to be able to condition the injection of js adequately.</p>
  
  <p>Any tips would be much appreciated.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-12-19T22:58:00.090Z
Comments.Text: Have a look here http://civicrm.stackexchange.com/a/12061 and here http://civicrm.stackexchange.com/a/11543 you can hook into angular declaring a 'fake/empty' module and loading it via hook_civicrm_angularModules, then you can target CiviMail's angular Directives, Services, Controllers, etc and change their behaviour when crmMailing bootstraps
Comments.UserDisplayName: Andrei
Tags: <angular>
Title: modifying angular form (new mailing)
ThreadText: # modifying angular form (new mailing)
  
  (Asked by: username_0 on 2016-12-19)
  
  I'm wrestling with where and how to best make modifications to the CiviMail new mailing form, built with Angular. There are several other questions addressing this in part, but none address my needs completely.
  
  The customization is pretty simple: include the logged in user's email as an option in the From Address selector and set it as the default.
  
  What I've found is that:
  
  1) I can't simply modify the from address list using the optionValues() hook. There are some oddities with from\_email\_addresses passed to that hook -- not all of the values are passed for modification. And because the select2 widget in the angular form is set to filter on is\_active, any values I add via the hook are ignored (the hook only let's me work with the basic option list; I have no access to other record metadata).
  
  2) Even if I use a php override of the CRM/Mailing/Info.php file and alter the from address values passed to angular, the default value is being set in some mystery way that I've not been able to find. Altering the is\_default value and weight so that my desired option is the default has no impact.
  
  3) In general, it seems very difficult to target angular forms via a hook in order to inject js. Maybe I'm missing something obvious, but the pageRun() hook doesn't seem to give me enough to be able to condition the injection of js adequately.
  
  Any tips would be much appreciated.
  
  **Tags:** angular
  
  > **Comments:**
  > **username_1**: Have a look here http://civicrm.stackexchange.com/a/12061 and here http://civicrm.stackexchange.com/a/11543 you can hook into angular declaring a 'fake/empty' module and loading it via hook_civicrm_angularModules, then you can target CiviMail's angular Directives, Services, Controllers, etc and change their behaviour when crmMailing bootstraps  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2016-12-19. Score: 1
  
  What about modifying the option list itself? So pick a hook that fires whenever the new mailing page is loaded (hook pageRun or something) and use the api to check if the current user's email is an option in that list. If not, add it
  
  That gets you halfway there... not sure about setting it as the default. I suppose if you made it the default every time the hook fires, then it would temporarily be the default for whoever is composing a mailing.
  
  > **Comments:**
  > **username_0**: per my observation 3 above, there's no clear way to target the mailing form via pageRun(). the object passed to the hook has elements generic to all angular pages -- I don't see any way to filter by the mailing page.  
  
  ---
  
  