How to set default value for the cdd element?

sales2010

Well-Known Member
Hello,

I need to set a default value for a cdd element, in this case it should be 0. I have added into element in the "Default" area, but it doesn't appear in form. Same problem using the option "Please select", the <option value> is empty

Code:
<select id="contracte_campuri___status_camp_6" class="fabrikinput inputbox readonly" size="1" name="contracte_campuri___status_camp_6[]">
<option value=""></option>
</select>

I use the latest github version, Joomla 3, Intranet.

Thank you
 
Hmmm. I don't think a default value of 0 will work in a CDD, as that won't exist as a key for the join element your are watching. The CDD works slightly differently to other elements, in that it sets itself up when the form is loaded, by doing an AJAX call (the same call it makes when you change the watched element), with the value of the watched element. Then it attempts to select the option from the returned 'SELECT' options which has a value that matches the CDD's current value.

So with the code as-is, you can only use a default value which would actually exist in the CDD's options for the default state of your of your watched element. So if your watched element was (say) US States, which defaulted to Alabama, you'd have to choose a default for your US Cities CDD element belonged to a city in AL.

I think in order to "fix" this, we'd also need to provide a "Please Select value" as well as a "Please Select label", like we do in the join element.

I'll add a github issue on this. I just have a feeling there were some deeper issues involved in this, which is why we didn't add the "Please Select value" option in the first place.

-- hugh
 
Thank you, Hugh,

Unfortunately, my watched element it's also a cdd element; this is my configuration now:

Services = Dbjoin element
Class = CDD
Subscription plan = CDD

What could be the syntax in this case?
 
Off topic: when i want to edit the post i get this message:

The following error occurred:

The time limit to edit this message (0 minutes) has expired.

[test edit by hugh]
 
You should be able to edit your own posts any time now. You may have to log out and back in again to pick up the new permission, I'm not sure.

As for the Join -> CDD -> CDD daisy chain, that should affect anything. It would still require the code change I mentioned.

Just so I understand the situation clearly, can you explain why you need to set the default to 0? Is it just that you want 0 entered in the table for the CDD field if a value is not selected, or do you need 0 for validation purposes, or what?

-- hugh
 
Yes, i need it for validation purpose, so if the value = 0 then hide the textfield, else show it.

The values should be retrieved dynamically, as long i need to use this element also for notempty validation, so if value == 1 then textfield will be visible and mandatory for one type of users, else if ==2 for another type of users..until value ==4 :)
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top