Page 1 of 1

Add custom fields/inputs unrelated to the database

PostPosted: Thu Dec 18, 2008 6:59 am
by GrosBedo
Hello,
Long time I didn't come to this forum, but Xataface fulfilled all my needs :-)

Just got a question: is there a way to add in the Edit form a custom field unrelated to the database ?

Concrete example: I want to put a checkbox to notify all registered users of the new article the admin is posting, if he checks the box. I know I'll have to use triggers, but I just can't figure out how to add a checkbox without having to create a fake row in the database.

Thank you much in advance !

PostPosted: Thu Dec 18, 2008 8:05 am
by shannah
Yes. You can add a transient field via the fields.ini file for this purpose.

e.g.

Code: Select all
[send_notification]
    transient=1
    widget:type="checkbox"
    widget:label="Please check this box if you want to send out a notification"


Then in your beforeSave() trigger:

Code: Select all
function beforeSave(&$record){
    if ( $record->val('send_notification') ){
        // do notification stuff here.
   }
}


Hope this helps.

Steve

PostPosted: Tue Dec 23, 2008 10:03 am
by GrosBedo
Thank you very much ! Exactly what I needed :D