|
3. Hours with options |
This application is situated in the example3 folder. To run it on your own server you need to create its table and data by executing the SQL in the file 'examples.sql/example3.sql'. To try it out on the phpPeanuts website click here.
It extends a copy from example 2 with two properties whose values can be selected from option lists and a third one whose value can be selected through a dialog.
The first is the 'gender' property. It was added to the class . It holds instances from the class . The class Gender extends the class , which is a special superclass for used as options. PntIdentifiedOption defines an id property for identification of the option, and a label property for presentation. The class Gender redefines the id property to be of type 'string'. The actual list of Gender instances is defined in the static method '' on the class Gender itself. This method also defines the order in which the options are presented in a list.
The second is the 'category' property. It was added to the class . It holds instances of the class . The class HoursCategory is just another class of peanuts. The options list consists of all its instances. The user can maintain the options list from the HoursCategory IndexPage, accessable throug a hyperlink in the application submenu.
The third is the 'country' property. It was added to the class . It holds instances of the class . The class Country is yet another class of persistent peanuts. The only reason why the values of 'country' are selected with a dialog instead of a select list is because there are so many countries in the database. Or, to be more exact, because the number of countries in the database exceeds the threshold defined in . It can be overridden in or special purpose subclasses.
In the class Country the id property inherited from DbObject has been overridden: its type is string instead of number. This allows the iso code to be used as id, and as foreign key in the Employee>>countryId property. |
|