Page 1 of 1

How do I set my database field to a checkbox?

PostPosted: Thu Mar 03, 2011 9:00 am
by JSours
I have a database field that I want to be set to a checkbox in edit view.
I went into the fields.ini and put:

[myDbFieldHere]
widget:type = "checkbox"

nothing happens...

Re: How do I set my database field to a checkbox?

PostPosted: Thu Mar 03, 2011 9:03 am
by shannah
That's the correct syntax. Things to look for if it isn't taking effect:

0. Make sure that it is picking up the fields.ini file at all. Try changing some other settings in the fields.ini file to ensure that it is being picked up if you're not sure.
1. Check the name of the field. Make sure it is exact (it is case sensitive).
2. Check to make sure that you don't have 2 sections in your fields.ini file for the same field.

-Steve

Re: How do I set my database field to a checkbox?

PostPosted: Thu Mar 03, 2011 9:23 am
by JSours
Ah ha it was not in the right directory so it was not reaching the field.ini file.

Thank You

Another question, How would I get the users login name from xataface into a field in my database automatically when inserting a new record? I was also trying to figure out getting the current date/time automatically as well.

Re: How do I set my database field to a checkbox?

PostPosted: Thu Mar 03, 2011 9:48 am
by shannah
Implement the beforeInsert() trigger in the table delegate class, and make use of the Dataface_AuthenticationTool's getLoggedInUsername or getLoggedInUser method:

Code: Select all
function beforeInsert($record){
    $authtool = Dataface_AuthenticationTool::getInstance();
    $username = $authtool->getLoggedInUsername()
    $record->setValue('posted_by', $username );
}

Re: How do I set my database field to a checkbox?

PostPosted: Thu Mar 03, 2011 11:35 am
by JSours
i'm getting a parse error on line 29 which is the line:

$record->setValue('myDatabaseFieldNameHere', $username );

Re: How do I set my database field to a checkbox?

PostPosted: Thu Mar 03, 2011 11:47 am
by shannah
Sorry.. my example is missing a semicolon at the end of the previous line.

-Steve

Re: How do I set my database field to a checkbox?

PostPosted: Thu Mar 03, 2011 11:49 am
by JSours
Thank you!