• crowwoods1

    (@crowwoods1)


    I’m trying to add:

    the values in 33 separate fields (possible daily actions) for the same participant. Can I put the [pdb_total filter=”energy_turn_lights_off>0&energy_unplug_chargers>0&….”] in the attributes of the Total daily action points field? And then take the total and multiply by 10? Actually, the participant can only select 8 daily actions, but I wouldn’t know which 8.

    the number of 17 separate fields with checkboxes (possible one-time actions) for the same participant. Can I put [pdb_total filter=”energy_change_to_led_lights.checked===true&nature_plant_a_tree.checked===true….”] in the attributes of the Total one-time action points field? And then take the total and multiply by 25?

    If not, how do I do that? Thanks!

Viewing 3 replies - 16 through 18 (of 18 total)
  • Plugin Author xnau webdesign

    (@xnau)

    The code won’t work without changes unless you happen to have 3 fields with the same name as the 3 fields in the demo plugin.

    Second, it is important to know what the data for each of those fields is. For example, if some of that data is not valid, it can cause the addition to fail. “Valid” in this case means it must be a number. Also, if some of the fields are empty, that could cause problems.

    If the addition fails, that will be logged, so you should be able to see the details of that failure in your php error log.

    The code I offered is extremely basic, really only meant to serve as a starting point. For example, it doesn’t do any checking to see if the record data is valid, you would need to add that if you have a situation where some of the fields may not contain a valid number.

    Another thing to check is the field that keeps the total ($total_field in the example code) must be present in the form that is submitted, either as a read-only field or as a hidden field because there is a security feature that prevents the user from adding data to the submission for fields that are not cleared for inclusion.

    Thread Starter crowwoods1

    (@crowwoods1)

    Yes, I added the 3 fields to my database. That’s how come it worked initially. All the fields are numeric. All the input fields have a default of 0.

    There is no error in the addition in the log. After I saved the record, I get —
    PDb_Participant_Cache::refresh_cache: Refreshing Participants Database cache for cache group 0
    Is that ok?

    You mean the ‘numeric_sum’ field must be read-only or hidden? I didn’t before, but now that field is read-only. I added a default value of 0 for it too.

    The other puzzling thing is each time I deactivated it to edit the file, and then go and copy and rename and edit the file in my host directory, the total-field plugin file shows up as 2 files in wp, and I would to figure out which one to reactivate. Then I would activate one and see if that’s the right one. If I then delete the wrong one, both plugin files would be deleted. Is that related to what’s wrong? Should I edit it in the wp plugin editor instead?

    Plugin Author xnau webdesign

    (@xnau)

    If you upload a plugin twice with a different name, then you will have both plugins installed. If you need to delete one of them, you must use FTP (or your hosting control panel File Manager) to do that. If you try to delete the plugin on the Plugins page, WP will delete both versions.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Adding Multiple Fields of One Participant’ is closed to new replies.