How do I set my database field to a checkbox?

A place for users and developers of the Xataface to discuss and receive support.

How do I set my database field to a checkbox?

Postby JSours » Thu Mar 03, 2011 9:00 am

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...
JSours
 
Posts: 12
Joined: Tue Mar 01, 2011 8:45 am

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

Postby shannah » Thu Mar 03, 2011 9:03 am

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

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

Postby JSours » Thu Mar 03, 2011 9:23 am

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.
JSours
 
Posts: 12
Joined: Tue Mar 01, 2011 8:45 am

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

Postby shannah » Thu Mar 03, 2011 9:48 am

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 );
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

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

Postby JSours » Thu Mar 03, 2011 11:35 am

i'm getting a parse error on line 29 which is the line:

$record->setValue('myDatabaseFieldNameHere', $username );
JSours
 
Posts: 12
Joined: Tue Mar 01, 2011 8:45 am

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

Postby shannah » Thu Mar 03, 2011 11:47 am

Sorry.. my example is missing a semicolon at the end of the previous line.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

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

Postby JSours » Thu Mar 03, 2011 11:49 am

Thank you!
JSours
 
Posts: 12
Joined: Tue Mar 01, 2011 8:45 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 22 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved