Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.2

Request #2889 Automatically create checkboxes for reverse links in forms
Submitted: 2004-12-04 15:51 UTC
From: c dot schneider at scram dot de Assigned: justinpatrin
Status: Closed Package: DB_DataObject_FormBuilder
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 38 - 30 = ?

 
 [2004-12-04 15:51 UTC] c dot schneider at scram dot de
Description: ------------ Lets begin with a table setup again: car id name person_id person id name my database.links.ini contains: [car] person_id = person:id So in a car form I get a select for person. It would be very nice to also get checkboxes in a car form that list all persons so I can set their owners this way. Is that possible at the moment?

Comments

 [2004-12-04 21:24 UTC] justinpatrin
Please clarify your request. Checkboxes would make no sense as there is *one* link field and *one* possibility. This is why it's a drop-down. If what you mean is radio buttons, then you can use the linkElementTypes config option: http://opensource.21st.de/tiki-index.php?page=Formbuilder+configuration+options#id750431 If you actually meant to say checkboxes in the *person* form to choose what cars are theirs this could be a possibility, but it would by no means be automatic. The potential for bloated forms would be enormous.
 [2004-12-05 00:14 UTC] c dot schneider at scram dot de
I meant in the person form .. sorry for the error. It should not be completely automatically of course. Perhaps with a config variable like display_fields. e.g. var $fb_display_reverse = array('car:person_id') in the person dataobject. What means : display reverse links from table car field person_id.
 [2004-12-05 00:31 UTC] justinpatrin
The other problem with this is that reverse links are not directly accessible. FB would have to search through *all* links to find them. In addition, it's wholly possible for someone to simply override link() in the DO instead of using the INI file, which would render this feature worthless. I would consider this more useful if you have to specify what tables you want reverse links for. E.g. in the person DO you would do: var $fb_reverseLinks = array(array('table' => 'car')); or var $fb_reverseLinks = array(array('table' => 'car', 'field' => 'person_id'));
 [2004-12-05 00:39 UTC] c dot schneider at scram dot de
Seems we want the same thing then ;-) That solution would be automatic enough for me.
 [2004-12-12 07:29 UTC] justinpatrin
Hmmm. One more possible problem here. Checking one of these checkboxes will switch the link from another record to the current one. This is *ok*, but there's no real insight into what you're switching it *from*. Also, if you un-check a checkbox....what happens then? If the link field is allowd to be NULL, it could be switched to NULL, but what if it's a NOT_NULL field? It all seems a little more destructive than I'd like...
 [2004-12-14 18:31 UTC] justinpatrin
Changing status to Feedback. I'd like more discussion on how this should work before implementing anything.
 [2004-12-16 00:41 UTC] c dot schneider at scram dot de
One possible solution to see what you are switching a field from is to display the current value beside. A list could look like this: [checkbox] [linkDisplayFields of Car] [linkText] [linkDisplayFields of Person the car links to] e.g. [ ] BMW owned by Peter [x] Jeep [ ] Beetle owned by Eve Where link text could be an additional attribute for fb_reverseLinks. As you said it is destructive in the sense that checking a box removes the old owner. I hope the user understands what he is doing ;-) The not null problem is very real of course. If the field person_id is defined not null this means the car must always be linked to a person. In this case the reverse link list makes not much sense. Formbuilder should check this and display an error when a reverse link is to be displayed and to originating field is defined not null. In any case the list could be also used just as an information. So you can see what cars a person owns. Each item of the list could link the the edit form of the car. Though I am not so sure the edit form is the right place for it. Normally there is also a non editable details page for each table that could also contain this.
 [2004-12-16 01:06 UTC] justinpatrin
Sounds like a decent idea. I like the linkText and displaying the currently linked object idea. I can think of a few more things. * linkText could default to ' - currently linked to - '. * we could add an option "defaultLinkValue" which sets the value of the link field if it's unchecked * if there's no default value and the field is NOT_NULL we could do a few things ** add rules to the QF so that checked fields may not be unchecked ** freeze or disable checked options (possibly add a message to the label to tell why) (also possibly add the above rules for sanity) ** freeze the entire group (i.e. make it informational) ** process as normal, but refuse to process "unchecked" boxes (maybe display a message) ** put in a QF rule which errors out when checks are unchecked and says the link field will be set to '0' if you click submit again ** simply error out when the form is created with a message to set the defaultLinkValue Also, the "links to the car form" wouldn't work as FB itself only deals with one form. I could do this with my Frontend package. ;-)
 [2005-01-02 06:44 UTC] justinpatrin
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. I've added reverseLinks as a config option. Please see the wiki for the full run-down. http://opensource.21st.de/tiki-index.php?page=Formbuilder+configuration+options#id909854