As we have already known, by default, PHPMaker will add an item into the Select Option (ComboBox) which has a default value of "" (blank string) and a default label value of "Please Select". This following trick will show you how you can hide or replace that "Please Select" option from the Select Option (ComboBox) in websites that generated by PHPMaker 8.0.3. Sometimes, you need this trick in order to replace that item with your own value which has a value other than a blank string, for example, the new value become "-" and the custom label become "...".
In addition, this trick will be very useful when you want to allow the value of "-" being saved for the certain field that represented by the ComboBox object in the form your web application. In the other words, this "-" option value will not be derived from your database along with the other records that displayed in that ComboBox.
[hidepost]
- Open your PHPMaker project (.pmp) file using PHPMaker application.
- Select or click on your desired table/view item.
-
Click on the Server Events/Client Scripts tab, then go to Server Events -> Table Specific -> Common -> Row_Rendered, and then add the following code into the function Row_Rendered():
if (CurrentPageID() != "list" && CurrentPageID() != "search") { $this->YourFieldName->EditValue[0] = array("-", "-", ""); // change the YourFieldName with your real field name. } -
Please note, that the EditValue is an array of options. In order to view the properties of field class, use the following code:
var_dump($this->YourFieldName);
You can call that var_dump code from that Row_Rendered function.
-
Now, let's go back and take a look at the previous code that we have just added into your Row_Rendered function above:
$this->YourFieldName->EditValue[0] = array("-", "-", ""); // change the YourFieldName with your real field name.YourFieldName = adjust it with your field name.
EditValue[0] = the first item (started from index of 0)
array("-", "-", "") = in this example, the first element of the array is the Link field, the second element of the array is the Display field #1, and the third element of the array is the Display field #2.Make sure that those three elements of array are match with the number of property of the field that you are using in the related field in your PHPMaker application. In other words, you have to adjust the element of array with the maximum number of the element array that being used.
Again, in order to check the maximum array of element that being used by that field, then you can view the properties of field class using the following code from the Row_Rendered function:
var_dump($this->YourFieldName);
- Re-generate your .php files using PHPMaker application as usual, and enjoy the results!
[/hidepost]
hello,
Does this still work on 12.0.7? I can’t get it to work.
sorry, I just figured out that it can be controlled in the language file. Thanks. I love the tips and hints on this site.