How do I set my database field to a checkbox?
Archived from the Xataface Users forum.
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…
shannah — Thu Mar 03, 2011 9:03 am
That’s the correct syntax. Things to look for if it isn’t taking effect:
- 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.
- Check the name of the field. Make sure it is exact (it is case sensitive).
- Check to make sure that you don’t have 2 sections in your fields.ini file for the same field.
-Steve
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.
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 ); }
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 );
shannah — Thu Mar 03, 2011 11:47 am
Sorry.. my example is missing a semicolon at the end of the previous line.
-Steve
JSours — Thu Mar 03, 2011 11:49 am
Thank you!