php - Zf2 Callback Validator not passing all form values -


Currently set up a form using ZF2. Based on the comparison of the prices of 2 different elements on the form, I want to be able to validate the verification for the form. In the past, I used the callback verifier to pass in the values ​​of all forms, it seems that in my current scenario, only the value of the element can be validated to me.

How do I set up my form here

  public function __ composition ($$$) {$ this- & gt; Setdi ($ di); Parents :: __ Construction (); $ Inputfilter = $ this- & gt; GetInputFilter (); $ This- & gt; Adjustment (Select Date: Class, ['label' = & gt; 'purchase date'], ['name' = & gt; 'buy_date', 'required' => 'true']); $ [This- & gt; Adelament (Select :: Class, ['Labels' = & gt; 'Which Card you used to make a purchase', 'Value_Voice' = & gt; ['' = & gt; '', 'credit' = '' Credit ',' debit '= & gt;' debit ']], [' expected '=> true,' name '= & gt;' card_type ',' helptext '= & gt;' card type']) ; $ This- & gt; Adm. (Submit: Category, [], ['value' = & gt; 'Claim']); $ InputFilter- & gt; (('' Name '= & gt;' card_type ',' validators' = & gt; array (array ('name' = & gt; callback :: class, 'option' = & gt; array ('message' = & Gt; Array (Callback :: INVALID_VALUE = & gt; 'Must be purchased in the last 6 years to claim the item'), 'callback' => function ($ value, $ context = []) { Var_dump (Func_get_args ()); // I need to be able to get both cardproof and purchase_data information; ();},))))))); }  

The problem is that currently var_dump (func_get_args ()) is currently returning only:

  array 2) {[0] = & gt; String (6) "credit" [1] = & gt; Array (1) {["card_type"] = & gt; In the past, I was hoping that this would also be passed as a part of the second code in the  buy_date  value. Callback 

Has anyone experienced this problem before? I am using the expected callback function in other areas of my application, but it does not seem to work here.

Thanks in advance

For clarification (though I believe it will not have any effect on verification), the function $ this-> AddElement is a function I have on my own and is simply:

{pre-> public function addElement ($ square, $ option, $ attributes) {$ this- & Gt; Add ($ this-> getDi () -> New instance ($ square, ['option' => = option]) - & gt; set properties ($ attributes)); }

This indicates that callbacks will only pass other values ​​which are input filters

P>

The solution is:

$ filter-> add (['name' = & gt; 'card_type', 'required' => true]);


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -