Delegate class php file example
Posted: Sun Dec 25, 2011 7:03 am
Maybe I just could not find the right place in the Wiki, but I had some trouble getting the delegate class file right due to finding only fragments.
So here is what I got working.
I wanted a field to have a default value filled in. The "function fieldname__default(){return 'something'}" does this.
The variables are fieldname and something.
Fieldname is the name of the field in your database.
Something is the value that you wish to have in the field by default.
<?php
class tables_tablename {
function fieldname__default(){
return 'something';}}
?>
The above example will fill in a field with a default value. The field would have the word "something" filled in.
<?php
class tables_tablename {
Above is the first section of the file. tablename is the name of the database table that the field, fieldname is in.
Notice the curly brace. The "function fieldname__default(){return 'something'}" goes in between a set of curly braces. Then finish off with ?>
I am not sure how you would place more than one function in this type of file. What syntax you might need as separators? What combination of curly braces?
This file has to be in a table directory. The same table directory that you would have fields.ini and valuelists.ini files in for instance.
Maybe a fuller example of this file structure could be added to the Delegate Class Wiki section?
So here is what I got working.
I wanted a field to have a default value filled in. The "function fieldname__default(){return 'something'}" does this.
The variables are fieldname and something.
Fieldname is the name of the field in your database.
Something is the value that you wish to have in the field by default.
<?php
class tables_tablename {
function fieldname__default(){
return 'something';}}
?>
The above example will fill in a field with a default value. The field would have the word "something" filled in.
<?php
class tables_tablename {
Above is the first section of the file. tablename is the name of the database table that the field, fieldname is in.
Notice the curly brace. The "function fieldname__default(){return 'something'}" goes in between a set of curly braces. Then finish off with ?>
I am not sure how you would place more than one function in this type of file. What syntax you might need as separators? What combination of curly braces?
This file has to be in a table directory. The same table directory that you would have fields.ini and valuelists.ini files in for instance.
Maybe a fuller example of this file structure could be added to the Delegate Class Wiki section?