This topic is locked
[SOLVED]

 Add on the fly with dependant dropdowns issue

5/19/2010 5:53:24 PM
PHPRunner General questions
D
Dale author

Im posting this, as I have spent a day and a half now trying to sort out an issue that has come up with users and dependant dropdowns.

Ver 5.1 build 2503
I have three dropdown fields.

Zone - dependant on project. Add on the fly enabled. works fine.

Zone Area - dependant on Zone. Add on the fly enabled. works fine.

Area Location - dependant on Zone Area. Add on the fly enabled. works fine.
The issue is, when I say works fine, If the user first selects Zone, the Zone Area dropdown populates nicely. all good.

If the user then picks a Zone Area, the Area Location dropdown fills nicely. all good.

If the user then picks a Area Location all works nicely.

BUT, if a user is looking these three fields, each with Add on the Fly enabled.

If a user clicks the Add New on the Zone Area or Area Location, WITHOUT picking a Zone first or picking a Zone Area, the problems begin.
THe add on the fly works, but if selected out of order, it creates a record NOT attached to Zone or the Zone Area.
So, I have been working on the idea of just not show the Add new link on the second and third picklists if the first picklist is not filled.
How can I hide the dependant dropdowns ADD NEW links if there is no selected value in the master dropdown.
Confused.

Using Edit Inline or Add Inline the list displays with the below dependant dropdown columns in the list.
Zone - Add new Area - Add new Location - Add new

dependant on Zone dependant on Area
If I click the Add new link on a field out of order, fill it out and click Save, the window closes Im returned to the list with the added record displayed

in the picklist, but the data is not saved with the link information in the database. A refresh quickly looses the picklists.

This is an issue with the inline add and inline edit as well. What I would like is the field and the Add new link field to simply be hidden until the onchange of the master dropdown is filled out properly. Or at least just the Add new link dissappear if the master dropdown is not filled.
My experience is, you cant teach a user what they are supposed to do, you are supposed to guide them through the way you want.

Any help is greatly appreciated.
Thanks in advance.

J
Jane 5/20/2010

Dale,
I see what you're saying.

Unfortunately there is no easy way to solve this problem in the version 5.1 because there is no tool to return controls of added/updated record.

As workaround you can use simple add/edit pages: add custom JavaScript code to hide 'add new' link if value in the main dropdown was not changed. Probably you'll need to edit generated include/commonfucntions.php file to add ID to the 'add new' link.
In the PHPRunner 5.2 you can use JavaScript API and "Edit page: JavaScript onload events" to show/hide this link based on the value selected in the main drodpown. More info here:

http://xlinesoft.com/phprunner/docs/javascript_api.htm

D
Dale author 5/20/2010

Thanks for the thoughts. You hit it exactly on the head re the ver 5.1. Yesterday I was doing exactly as you mentioned, modding the commonfunctions.php

and the add, edit templates. I was just about there, but there was more work for the inline edit feature to be done. I was hoping there might have been a simpler magic fix.
I will continue, on. Looking forward to upgrading to 5.2, but need to make some money first.

Thanks again

D
Dale author 5/26/2010

Done. A bit of a chore, but I have managed to get this issue resolved by modifying commonfunctions.php, _add.php, _edit.php and corresponding templates.
I wanted to thank you Ann for confirming I was going in the right direction.
This may be an issue in the 5.2 that you may want to look at.
If you have multiple dependant dropdowns, with the Add on the Fly feature. Selecting the Add New link out of sequence caused me major issues as the records were not being saved with the appropriate dependancies on the other fields.
Example

I have a project that has Zones

The Zones have Areas (dependant on Zone)

The Areas have Locations. (dependant on Area)
PHPRunner nicely allows you to create 3 dropdown fields. Each one dependant on the previous selection.

So on a list when you display all three dropdowns, (again each one has the Add on the Fly function), and you select Add inline or Edit Inline, if a user picks the last dropdown and clicks ADD NEW,

It goes badly. And believe me users will do lots of wonderfull things.

The same applied to the Add and Edit records with these three dropdowns.
My solution was to hide the trailing dropdowns until their master dropdown was selected. Then the next dropdown appears.

Not so bad on the add and edit pages, but the inline add and inline edit were a challenge as they are ajax functions.
I have uploaded the project with my mods, we will see how the users deal with it. Once you fix something, they get more determined to break it.
Anyway Im rambling, point is, maybe the development team can have a look at some error checking on dependant drop downs. No picking the ADD NEW on a dependant dropdown that does NOT have the master dropdown selected.
Just a thought.

Keep up the great work.

If you want to see it in action you can still access my demo with the info from my previous post "Project Complete and gone Live". The access is still open for phprunner users.