Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Email placeholder

I was asked by our staff to insert a placeholder in the email field of the open ticket form which is fix, so that staff doesn't need to type this manually.

We don't force staff to register...

Is this possible?

Comments

  • edited August 22
    I think I understand what you mean, when creating a new ticket, have the domain name already there, so they only need to type their username.
    Once more I dove deep into the forms API and again rebuffed by it's complexity and weirdness.. also lack of comments.
    You could simply add a piece of JavaScript to the page, if empty, add your domain name, set the focus to the start of the text.. probably the easiest at this point.
    But seriously, if you figure out the forms, let me know asap!
  • I'm unable to check now, but can't you just go into admin > forms and edit the userform and set a default value for the email field?

    Otherwise
    For staff: https://github.com/osTicket/osTicket/blob/develop/include/staff/ticket-open.inc.php#L88
    Do a check if $info['email'] isset/empty then assign your default value else $info['email']
  • You can set a "placeholder", which is the half-visible text that indicates what could be typed, not an actual piece of text as a value though.

    I believe the "don't force staff to register" comment indicates the staff would be "Users", as unregistered they'd be using the client/open.inc.php template https://github.com/osTicket/osTicket/blob/develop/include/client/open.inc.php#L43

    So, I was trying to decipher the UserForm.. and it's defeated me again.. Can't figure out how it is defined, or even where. 
    Editing the field entry directly via JSON into the database, failed, default does nothing. 

    {"size":"40","length":"64","validator":"email","regex":"","validator-error":"Email error","placeholder":"your@email.address","default":"test@address.com"}

    Replacing placeholder with default, does nothing. It ignores it.

    If you check the options for the widget https://github.com/osTicket/osTicket/blob/develop/include/class.forms.php#L1245 it doesn't include a default value. Neither does it's parent class's config. 


  • edited August 23
    Yea i know that a placeholder is just an example and not actual input, but since he said that he didn't want them to have to type it, i presumed the terminology was incorrect.

    It looks like you'll need to edit these 3 spots in order to get default value to the textboxfield

    value="<?php echo Format::htmlchars((empty($this->value) ? $default : $this-value)); ?>"/>
  • @Micke1101 great find!
    I've apparently never read that far into the file. Such a big one, with no comments.. brutal.

    You would want to define default as an empty string as well, like your 3223 one:
    $default = isset($config['default']) ? $config['default']:'';

    Or if you were particularly vicious, just embed one ternary inside the other.. but don't. Lol.

    Then, to add the email domain, actually edit the JSON field definition by hand, or edit the configuration to add the widget to the admin form.
    This might well better as a pull request, I'm sure other forms text boxes could use a default value as well.
  • thanks guys for all the explanations here. I will try my best to implement it in our system. Thanks again and hopefully I'll be successful ;-)
  • I'd like to populate the email subject text box and the ticket issue textbox with static default text. (When a client creates a new ticket.)  Any ideas on how to do this? 
Sign In or Register to comment.