Turn Custom Field into Drop-Down list?
Moderator: mkoch227
-
- Posts: 5
- Joined: Wed Dec 12, 2007 4:09 am
Turn Custom Field into Drop-Down list?
Script URL:
Version of script: 0.94.1
Hosting company: server101
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution: custom, drop-down
Write your message below:
My knowledge of PHP is very limited. I like the idea of the custom fields. Is there anyone there that has changed one to a drop-down list like a combo box in Microsoft Access? I undertsand I would have to adapt the SQL code and the field structure in the SQL table.
I would appreciate it if anyone had some code to share and reveal how they were able to do this?
Regards
Anthony
Version of script: 0.94.1
Hosting company: server101
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution: custom, drop-down
Write your message below:
My knowledge of PHP is very limited. I like the idea of the custom fields. Is there anyone there that has changed one to a drop-down list like a combo box in Microsoft Access? I undertsand I would have to adapt the SQL code and the field structure in the SQL table.
I would appreciate it if anyone had some code to share and reveal how they were able to do this?
Regards
Anthony
I will try to include something in the next version, but I can't promise it. This has been asked before and I'm sure a lot of people are wondering how, so I will include basic instructions how to do it.
If you know HTML code and a little PHP you could get this working like this (may not be understandable if you don't know HTML):
1. in your browser open your page with the "Add a ticket" form (index.php?a=add) and view the HTML source code
2. you should see some code like this:
(<!--START CUSTOM and <!-- END CUSTOM will be there, the code between depends on how many custom fields you use and for what). In the above example we have this HTML code to show a text input
3. now you can modify this text input HTML code as you wish, the only thing that matters is that name remains name="custom1" (and there is a limit of 255 chars in the database for each custom field value).
For example to change it to a drop-down list you could use
4. Now what you need to do is edit index.php in a text editor, delete all PHP code between and and paste your edited HTML there. In the above case the code would be
Note: if in your HTML code you have START CUSTOM AFTER and END CUSTOM AFTER delete PHP code between those two tags instead of START CUSTOM BEFORE and END CUSTOM BEFORE
This should work. It's far from practical and you would have to edit the code every time you enable/disable more custom fields, but for now it's the only work-around.
If you know HTML you should be able to make this work, if not I suggest hiring someone to do it for you.
If you know HTML code and a little PHP you could get this working like this (may not be understandable if you don't know HTML):
1. in your browser open your page with the "Add a ticket" form (index.php?a=add) and view the HTML source code
2. you should see some code like this:
Code: Select all
<!-- START CUSTOM BEFORE -->
<table border="0"> <tr>
<td align="right" width="150">Optional custom: </td>
<td align="left" width="600"><input type="text" name="custom1" size="40" maxlength="255" value=""></td>
</tr>
</table> <hr><!-- END CUSTOM BEFORE -->
Code: Select all
<input type="text" name="custom1" size="40" maxlength="255" value="">
For example to change it to a drop-down list you could use
Code: Select all
<select name="custom1">
<option>First option</option>
<option>Second option</option>
<option>Third option</option>
</select>
Code: Select all
<!-- START CUSTOM BEFORE -->
Code: Select all
<!-- END CUSTOM BEFORE -->
Code: Select all
<!-- START CUSTOM BEFORE -->
<table border="0"> <tr>
<td align="right" width="150">Optional custom: </td>
<td align="left" width="600"><select name="custom1">
<option>First option</option>
<option>Second option</option>
<option>Third option</option>
</select></td>
</tr>
</table> <hr><!-- END CUSTOM BEFORE -->
Note: if in your HTML code you have START CUSTOM AFTER and END CUSTOM AFTER delete PHP code between those two tags instead of START CUSTOM BEFORE and END CUSTOM BEFORE
This should work. It's far from practical and you would have to edit the code every time you enable/disable more custom fields, but for now it's the only work-around.
If you know HTML you should be able to make this work, if not I suggest hiring someone to do it for you.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
-
- Posts: 5
- Joined: Wed Dec 12, 2007 4:09 am
-
- Posts: 5
- Joined: Wed Dec 12, 2007 4:09 am
Did you finish step 4. in my previous post?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
-
- Posts: 5
- Joined: Wed Dec 12, 2007 4:09 am
Klemen,
When you say index.php, I assume you mean I download the file from the server via ftp?
The code I get when I download it is:
<!-- START CUSTOM BEFORE -->
<?php
/* custom fields BEFORE comments */
if ($hesk_settings['use_custom'] && $hesk_settings['custom_place']==1) {
echo '<table border="0">';
foreach ($hesk_settings['custom_fields'] as $k=>$v) {
if ($v['use']) {
if ($v['req']) {$v['req']='<font class="important">*</font>';}
else {$v['req']='';}
$k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
echo <<<EOC
<tr>
<td align="right" width="150">$v[name]: $v[req]</td>
<td align="left" width="600"><input type="text" name="$k" size="40" maxlength="$v[maxlen]" value="$k_value"></td>
</tr>
EOC;
}
}
echo '</table> <hr>';
}
?>
<!-- END CUSTOM BEFORE -->
So, is this the file I have to change? When I load the page in the browser and view the source, all I see is the html code.
I appreciate you taking time to help me.
Anthony.
When you say index.php, I assume you mean I download the file from the server via ftp?
The code I get when I download it is:
<!-- START CUSTOM BEFORE -->
<?php
/* custom fields BEFORE comments */
if ($hesk_settings['use_custom'] && $hesk_settings['custom_place']==1) {
echo '<table border="0">';
foreach ($hesk_settings['custom_fields'] as $k=>$v) {
if ($v['use']) {
if ($v['req']) {$v['req']='<font class="important">*</font>';}
else {$v['req']='';}
$k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
echo <<<EOC
<tr>
<td align="right" width="150">$v[name]: $v[req]</td>
<td align="left" width="600"><input type="text" name="$k" size="40" maxlength="$v[maxlen]" value="$k_value"></td>
</tr>
EOC;
}
}
echo '</table> <hr>';
}
?>
<!-- END CUSTOM BEFORE -->
So, is this the file I have to change? When I load the page in the browser and view the source, all I see is the html code.
I appreciate you taking time to help me.
Anthony.
-
- Posts: 5
- Joined: Wed Dec 12, 2007 4:09 am
Drop down for one custom field
How can i put Drop Down menu Just for One Of the Fields? For Example Field 5, This way you have told make a Drop down but not for a certain custom field
Integrate in custom fiel
How can we integrate this drop down to be in the custom field?
I check data base it was not recorded.
Thanks
I check data base it was not recorded.
Thanks
I got it now.
Here is the sample working ===
<!-- START CUSTOM BEFORE -->
<?php
/* custom fields BEFORE comments */
if ($hesk_settings['use_custom'] && $hesk_settings['custom_place']==1) {
echo '<table border="0">';
foreach ($hesk_settings['custom_fields'] as $k=>$v) {
if ($v['use']) {
if ($v['req']) {$v['req']='<font class="important">*</font>';}
else {$v['req']='';}
$k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
echo <<<EOC
<tr>
<td align="right" width="150">Department: </td>
<td align="left" width="600"><select name="custom1">
<option>ALL Department</option>
<option>Dep 1</option>
<option>Dep 2</option>
<option>Dep 3</option>
</select></td>
</tr>
EOC;
}
}
echo '</table> <hr>';
}
?>
Here is the sample working ===
<!-- START CUSTOM BEFORE -->
<?php
/* custom fields BEFORE comments */
if ($hesk_settings['use_custom'] && $hesk_settings['custom_place']==1) {
echo '<table border="0">';
foreach ($hesk_settings['custom_fields'] as $k=>$v) {
if ($v['use']) {
if ($v['req']) {$v['req']='<font class="important">*</font>';}
else {$v['req']='';}
$k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
echo <<<EOC
<tr>
<td align="right" width="150">Department: </td>
<td align="left" width="600"><select name="custom1">
<option>ALL Department</option>
<option>Dep 1</option>
<option>Dep 2</option>
<option>Dep 3</option>
</select></td>
</tr>
EOC;
}
}
echo '</table> <hr>';
}
?>
Just for your information: in the next version it will be easy to choose custom field type (text, radio, select, text box (textarea)).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools