Subscribe: RSS
  • Here's the idea:
    There are 3 levels of "membership". when you choose a radio we tell the system what that name of that level is so I can put it on my receipt( [+level] ). There is a second value in the radio input under the data-cost attribute. I need to get that value to output to the receipt too and can't figure it out.

    Here's the code:
    <input type="hidden" name="level" value="" />
        <label>     
         <input class="required" type="radio" value="Member" name="level" [[!+fi.level:is=`Member`:then=`checked="checked"`]] id="Member" data-cost="[[+seminar_cost_member_price_early]]" />
         Member
        </label>
        <label>
         <input class="required" type="radio" value="Student" name="level" [[!+fi.level:is=`Student`:then=`checked="checked"`]] id="Student" data-cost="[[+seminar_cost_student_price_early]]" />
         Student
        </label>
        <label>
         <input class="required" type="radio" value="Non-Member" name="level" [[!+fi.level:is=`Non-Member`:then=`checked="checked"`]] id="Non-Member" data-cost="[[!+seminar_cost_member_price_early]]" />
         Non-Member
        </label>
    


    Using [+level] i can get the membership type, say, "Member" for example... but, how the heck to I output [[+seminar_cost_member_price_early]] to my receipt? I was thinking [+level.seminar_cost_member_price_early] or something like that

    thanks!

    (I know the placeholders need two ['s and two ]'s... just took them out so I could post)
      I LOVE MODX! | greyskymedia.com

      I'm always happy to help if I can.
      Add me to your Skype: jamison.mergens
    • where does this
      [[+seminar_cost_member_price_early]]
      come from?

      I think you will need a formit-hook, with some logic to get the price, depending on the selected level.

      or put the price to the value with an separator between or as json, which can be exploded by a formit-hook.
      • that value is in the db... i was thinking a hook too, i was just hoping there'd be an easier to program way to get that value... just having a hard time
          I LOVE MODX! | greyskymedia.com

          I'm always happy to help if I can.
          Add me to your Skype: jamison.mergens
        • So, basically I need a hook that says: get the value of [+level], then, based on which was selected get the value of data-cost, then spit that back as a placeholder of, say, [+levelCost]

          yes?
            I LOVE MODX! | greyskymedia.com

            I'm always happy to help if I can.
            Add me to your Skype: jamison.mergens
          • yes, you can fill new placeholders in a hook with
            $hook->setValue('levelCost',$cost);


            http://rtfm.modx.com/display/ADDON/FormIt.Examples.Custom+Hook
            • so my snippet would be:
              $cost = level; //create a placeholder "cost" by looking at "level" from the form
              $hook->setValue('levelCost',$cost); //turn the above into a hook
              return true; // fail if it's not true
              


              But how would i tell $cost to be the placeholder from the data-cost attribute??
                I LOVE MODX! | greyskymedia.com

                I'm always happy to help if I can.
                Add me to your Skype: jamison.mergens
              • Close. You don't want the cost on the front-end as users can change that. Do something like this:
                $levels = array(
                  'member' => 15,
                  'student' => 10,
                  'non-student' => 30,
                );
                
                $level = strtolower($hook->getValue('level'));
                if (isset($levels[$level]) && ($levels[$level] > 0)) {
                  $hook->setValue('levelCost', $levels[$level]);
                } else {
                  // either set a default value, or add an error
                  return false;
                }
                return true;
                  Hi there! I am Mark Hamstra, I am the owner and developer of modmore.com, a MODX and community focused business. I've released a fair number of Extras.
                  Tweet me @mark_hamstra, catch my infrequent blog at markhamstra.com and talk code at Github.
                • ooOOOooo fancy... but the value's of member, student and non-student change page to page... the form field values for [+seminar_cost_member_price_early] [+seminar_cost_non_member_price_early] [+seminar_cost_student_price_early] should pull from the db... thoughts?
                    I LOVE MODX! | greyskymedia.com

                    I'm always happy to help if I can.
                    Add me to your Skype: jamison.mergens
                  • Thanks to Mr.Perner and Mr. Hamstra I'm at least able to launch the site... I do still need to get things talking to the db properly though.

                    THANKS!
                      I LOVE MODX! | greyskymedia.com

                      I'm always happy to help if I can.
                      Add me to your Skype: jamison.mergens