asterisk2billing.org http://forum.asterisk2billing.org/ |
|
AddEditElement RADIOBUTTON, CHECKBOX how to? http://forum.asterisk2billing.org/viewtopic.php?f=18&t=3424 |
Page 1 of 1 |
Author: | mazhar996 [ Wed Mar 19, 2008 11:03 am ] |
Post subject: | AddEditElement RADIOBUTTON, CHECKBOX how to? |
Dear All, I have trying to add a new filed "Accept Terms" in the signup form with type either radiobutton or checkbox but with no success. I am playing with Class.FormHandler.inc.php and FG_var_index.inc in FG_var_index.inc if i add Code: $HD_Form -> AddEditElement (gettext("TERMS"),
"terms", '', "CHECKBOX", "", "", gettext("Please accept Terms and Conditions"), "" , "", "","", "", "" , "", ""); it doesn't display the checkbox, if i make it RADIOBUTTON, a radio button is displayed but i can not add $config_radiobouttonfield, I have tried different ways (there is a little hint in Class.FormHandler.inc.php) , adding an argument in function AddEditElement( , but nothing would help. i see that in calls to AddEditElement in FG_var_index.inc there are different number of arguments depending on the fieldtype but i do not no what should be the format and order of arguments for RADIOBUTTON. Please help. with sincere regards mazhar |
Author: | stavros [ Wed Mar 19, 2008 12:39 pm ] |
Post subject: | |
Take a look at an existing radio button such as this one from FG_var_card.inc: Code: $HD_Form -> AddEditElement (gettext("ACTIVATED"), I hope this is enough to get you going.
"activated", 't', "RADIOBUTTON", "", "", gettext("Choose if you want to activate this card"), "" , "", "" , "Yes :t, - No:f", "", "", "", "" ); |
Author: | mazhar996 [ Wed Mar 19, 2008 1:52 pm ] |
Post subject: | |
Great, that helps. many thanks indeed Added after 27 minutes: Hi Stavros, It doesn't really help, the new item is displayed on the signup page but when i submit the form, it displays error, "No such user found in database" Any tips? please advise |
Author: | stavros [ Wed Mar 19, 2008 2:19 pm ] |
Post subject: | |
That sounds to me like your modifications are causing the INSERT to fail, leading to the row not being available in signup_confirmation.php. Try setting '$HD_Form -> FG_DEBUG = 3;' near the top of signup/form_data/FG_var_index.inc, and perhaps even manually trying the INSERT statement on your SQL server. |
Author: | mazhar996 [ Wed Mar 19, 2008 2:38 pm ] |
Post subject: | |
Hi Stavros, I am lucky that you are responding today. So i would use this oppertunity. I have tried with $HD_Form -> FG_DEBUG = 3; and it does nothing except showing the all countries in signup page. I do not know which query its using to insert the data, and how could i try manual insertion. If this is what makes up the insertion query: Code: $HD_Form -> FieldEditElement ('username, useralias, uipass, credit, language, tariff, id_didgroup, id_campaign,'.
'callback, activated, simultaccess, currency, runservice, typepaid, creditlimit, firstusedate, enableexpire,'. 'expirationdate, expiredays, vat, lastname, firstname, email, address, city, state, country, zipcode, phone,'. 'fax, captchacode, sip_buddy, iax_buddy, inuse'); Then I have tried with adding terms (name of the new field) after fax but still caused the same error. I experimented with simply changing the fax filed type to radiobutton keeping the name same and it proceeds correctly. I believe there is some limit on number of fileds in this form or i need handel the extra posted field (terms in this case) somewhere like other fields (phone,fax etc.) btw have you ever tried adding a new field in signup page? I would be really thankful to you for your kind guidance. regards mazhar |
Author: | stavros [ Wed Mar 19, 2008 4:22 pm ] |
Post subject: | |
mazhar996 wrote: I have tried with $HD_Form -> FG_DEBUG = 3; and it does nothing except showing the all countries in signup page. It was my hope that by increasing the debug level of the framework it would show you the query. Looking at function perform_add in Class.FormHandler.inc.php shows that setting debug level 1 might do what I hoped.I do not know which query its using to insert the data, and how could i try manual insertion. Quote: btw have you ever tried adding a new field in signup page? No.
|
Author: | mazhar996 [ Wed Mar 19, 2008 6:38 pm ] |
Post subject: | |
This is what i see when using debug 1 language : de currency : EUR -> lastname => ^.{2} , Abbas lastname : Abbas -> firstname => ^.{2} , Mazhar firstname : Mazhar -> email => ^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$ , [email protected] email : [email protected] -> address => ^.{3} , heinrich address : heinrich -> city => ^.{3} , berlin city : berlin -> state => ^.{2} , berlin2 state : berlin2 country : DEU -> zipcode => ^.{3} , 10179 zipcode : 10179 -> phone => ^[0-9][ .0-9\/\-]{6,}[0-9]$ , 49 30 4200 4972 phone : 49 30 4200 4972 fax : terms : -> captchacode => ^(F3LI4C)|(f3li4c)$ , captchacode : -------------------------------------------------------------------------------- language, currency, lastname, firstname, email, address, city, state, country, zipcode, phone, iax_buddy, sip_buddy, expiredays, expirationdate, typepaid, enableexpire, runservice, simultaccess, activated, credit, username, useralias, uipass, userpass, loginkey, activatedbyuser, tariff -------------------------------------------------------------------------------- 'de', 'EUR', 'Abbas', 'Mazhar', '[email protected]', 'heinrich', 'berlin', 'berlin2', 'DEU', '10179', '49 30 4200 4972', '1','1','0','2018-03-19 19:35:02','0','0', '0','0','t','0','60323','37966334','5731649751','60323','bjd6aykpclq6byzcwk8o','f', '3' The insertion query seems to be OK to me, as it niether include new item nor captchacode. So theoratically there shouldn't be any issues. Does it say something to you? |
Author: | stavros [ Wed Mar 19, 2008 7:02 pm ] |
Post subject: | |
Not really. Except the 'fax' field isn't populated at all. I'm no expert at coding for Areski's framework too and it's difficult to know what you've changed so I'm sorry but I have no further suggestions. |
Author: | mazhar996 [ Wed Mar 19, 2008 9:08 pm ] |
Post subject: | |
The only change i made is copy of Code: $HD_Form -> AddEditElement (gettext("ACTIVATED"),
"activated", 't', "RADIOBUTTON", "", "", gettext("Choose if you want to activate this card"), "" , "", "" , "Yes :t, - No:f", "", "", "", "" ); from FG_var_card.inc as you suggested. The fax field is not populated because i didn't enter any value into it and its not compulsary field. If i remove the above code then still the insertion query is the same and signup completes. Anyhow i hope that someone comes up with a solution, perhaps areski sees this post accidentaly. How is it btw, does he receive copy of every post? regards mazhar |
Author: | asiby [ Wed Mar 19, 2008 10:04 pm ] |
Post subject: | |
I will assume that your new terms field is to be displayed right after the fax field. Near the beginning of the data file, you will see something like: Code: getpost_ifset(array('id', 'username', 'useralias', ..., 'fax', ... )); Would become ... Code: getpost_ifset(array('id', 'username', 'useralias', ..., 'fax', 'terms', ... )); You must add your new 'terms' field to it. That is how your data is going to be read when the form is submitted. I see that you have already added the field with: Code: $HD_Form -> AddEditElement (gettext("TERMS"), "terms", '', "CHECKBOX", "", "", gettext("Please accept Terms and Conditions"), "" , "", "","", "", "" , "", ""); That's good. Now you have to add that terms field IN THE SAME ORDER in which they have been declared: Code: $HD_Form -> FieldEditElement ('username, useralias, uipass, credit, language, tariff, id_didgroup, id_campaign,'.
'callback, activated, simultaccess, currency, runservice, typepaid, creditlimit, firstusedate, enableexpire,'. 'expirationdate, expiredays, vat, lastname, firstname, email, address, city, state, country, zipcode, phone,'. 'fax, terms, captchacode, sip_buddy, iax_buddy, inuse'); Notice how I have added it right after the fax field. Depending on the situation, you will need to add a corresponding database field in the relevant table. After doing theses changes, you should be ok. Let us know if it works. Cheers |
Author: | stavros [ Thu Mar 20, 2008 12:08 am ] | ||
Post subject: | |||
Nice one asiby. I didn't get any output when using the framework's 'CHECKBOX' field type, and I couldn't find an example of its use to borrow from. I changed it to use a radiobutton: Code: $HD_Form -> AddEditElement (gettext("TERMS"), This depends on a new regular expression in Class.FormHandler.inc.php:"terms", "$terms", "RADIOBUTTON", "", "20", gettext("You must accept the terms and conditions"), "" , "", "","Yes:t, No:f", "", "" , "", gettext("Please confirm you have read and accept the Terms and Conditions.")); Code: // 20 TEXT 'Y', 'y', 'T', 't' or '1' This seems to function well.
$this -> FG_regular[] = array( '^[TtYy1]$', '');
|
Author: | mazhar996 [ Thu Mar 20, 2008 2:44 pm ] | ||
Post subject: | |||
Ok I just thought I should upload my working copy of FG_var_index.inc for all of those who might have same requirements. Apart from FG_var_index.inc , one needs to add an expression check in Class.FormHandler.inc.php what i did was after the line 956 i added following Code: // 20 TERMS
$this -> FG_regular[] = array( "[t]", gettext("(Please confirm you have read and accept the Terms and Conditions.)")); Also please add a column named terms in cc_card
|
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |