I Love PHPMaker

... because it gets even more powerful and flexible!!

  • About
  • Terms and Conditions
  • Membership Options
  • Sitemap
  • Downloads
    • PHPMaker Extensions Download
    • PHPMaker Projects Download
    • PHP Report Maker Extensions Download
I Love PHPMaker » Tips and Trick » How to Remove “Please Select” from the Select Option in Websites that Created with PHPMaker 8.0.3
How to Change Vertical-Align of CheckBox Item, View, Edit, and Copy Links from Middle to Top on List Page in Websites that Created with PHPMaker 8.0.3
How to Add the Password Strength Meter and Password Validation Features on Registration Page in Websites that Generated With PHPMaker 8.0.3

April 7, 2012

How to Remove “Please Select” from the Select Option in Websites that Created with PHPMaker 8.0.3

Have you ever read the article I wrote about how to hide or change the "Please Select" words with your own words including its value? Well, the following trick will show you how to remove the "Please Select" option from the Select Option in websites that created with PHPMaker, instead of to replace the "Please Select" words and its value.

This trick is very useful whenever you want to remove the "Please Select" option completely from the Select Option (Combobox) without having to modify the generated script files. I repeat: without having to modify the generated script files. Now let's take a look at the following example. In the Add page, you want to limit the options that belongs to the UserID field, by displaying the current logged UserID, and then by default you only want to display the only UserID. In order to automatically select the only UserID in the Combobox, then we should remove the "Please Select" option. If we do not remove that "Please Select" option, then by default it will automatically select the first option ("Please Select"), so your user has to change the selected option with another one you have in it. After removing that first option, now we only have the only option (UserID), and it will automatically be selected when you load that Add page.

As I mentioned before, we will not modify the generated script files at all. We only use the Row_Rendered() function from the Server Events that provided by PHPMaker for this purpose, and it works perfectly as we want!

Doesn't it sound great? Curious? 😉

[hidepost]

  1. Open your PHPMaker project (.pmp) file by using PHPMaker.
  2. From the Database setup, click one of your desired table, and then click on the Server Events/Client Scripts tab. Go to Server Events -> Table-Specific -> Common -> Row_Rendered, and then insert the following code to your Row_Rendered() function that located in the editor code at the right pane of your PHPMaker:

      if (CurrentPageID() != "list" && CurrentPageID() != "search") {
        array_shift($this->iduser->EditValue); // Remove the first option using PHP function: array_shift
      }
    

    If you have never modified that Row_Rendered() function, then the complete code would be like this:

    // Row Rendered event
    function Row_Rendered() {
      // To view properties of field class, use:
      //var_dump($this-><FieldName>);
      if (CurrentPageID() != "list" && CurrentPageID() != "search") {
        array_shift($this->iduser->EditValue);
      } 
    }
    

    Please note that if, from the example above, iduser field is one of your primary key so this field will become read-only while your user is editing the record, then change this code:

    if (CurrentPageID() != "list" && CurrentPageID() != "search") {
    

    become the following:

    if (CurrentPageID() != "list" && CurrentPageID() != "search" && CurrentPageID() != "edit") {
    

    In other words, this will prevent an error/warning message "array_shift() expects parameter 1 to be array, string given". Hope that helps!

  3. Save the project, and then re-generate your script files using PHPMaker as usual.

[/hidepost]

Article by Masino Sinaga / Tips and Trick / array_shift, ComboBox, PHPMaker 8.0.3, PHPMaker 9.0.2, Please Select, Row_Rendered, Server Events Leave a Comment

How to Change Vertical-Align of CheckBox Item, View, Edit, and Copy Links from Middle to Top on List Page in Websites that Created with PHPMaker 8.0.3
How to Add the Password Strength Meter and Password Validation Features on Registration Page in Websites that Generated With PHPMaker 8.0.3

Leave a Reply Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • A New PHPMaker 2025 Project File Is Released
  • PHPMaker 2025 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2025 Is Released!
  • A New PHPMaker 2024 Project File Is Released
  • PHPMaker 2024 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2024 Is Released!
  • PHPMakerProjects.com, For Those Who Need PHPMaker Project Sample
  • A New PHPMaker 2023 Project File Is Released
  • PHPMaker 2023 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2023 Is Released!

Search

Recent Comments

  • Masino Sinaga on Masino Extensions for PHPMaker 2024 Is Released!
  • Masino Sinaga on A New PHPMaker 2024 Project File Is Released
  • Masino Sinaga on PHPMaker 2023 Demo Project File Is Released
  • Edward Babatunde on PHPMaker 2023 Demo Project File Is Released
  • Edward Babatunde on Masino Extensions for PHPMaker 2024 Is Released!

Demo Website

  • Demo of I Love PHPMaker 2025 (MasinoExtensions).
  • Stock Inventory Management for PHPMaker 2025.

Another Demo

The following template are not available in this site (must be purchased separately)

  • PHPMaker v2018 Horizontal Vertical Template.
  • PHPMaker v2017 Horizontal Vertical Template.

Demo Explanation

Stock Inventory Management is the good project for your reference, since it uses the real example in the real world. Many useful features you can use from this project, such as how to add the Thousand and Decimal separator character, and also how to calculate multiple row in Grid-Add when End-Users are entering data into the Grid-Add mode.

Categories

  • Customize Template (103)
  • General (4)
  • PHP Report Maker (17)
  • PHP Report Maker Extensions (2)
  • PHPMaker Extensions (84)
  • PHPMaker Projects (7)
  • Tips and Trick (72)

Articles based on version

  • PHPMaker 2025
  • PHPMaker 2024
  • PHPMaker 2023
  • PHPMaker 2022
  • PHPMaker 2021
  • PHPMaker 2020
  • PHPMaker 2019
  • PHPMaker 2018
  • PHPMaker 2017.0.7
  • PHPMaker 12.0.7
  • PHPMaker 11.0.6
  • PHPMaker 10.0.5
  • PHPMaker 9.2.0
  • PHPMaker 8.0.3
  • PHP Report Maker 12

(c) I Love PHPMaker 2010 - 2025 by Masino Sinaga | WordPress | Log in | Back to top