Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Tue Apr 07, 2020 4:28 pm
Hosted Voice Broadcast


All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: AddEditElement RADIOBUTTON, CHECKBOX how to?
PostPosted: Wed Mar 19, 2008 11:03 am 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 12:39 pm 
Offline
Moderator
User avatar

Joined: Thu Jun 22, 2006 2:19 pm
Posts: 2890
Location: Devon, UK
Take a look at an existing radio button such as this one from FG_var_card.inc:
Code:
$HD_Form -> AddEditElement (gettext("ACTIVATED"),
            "activated",
            't',
            "RADIOBUTTON",
            "",
            "",
            gettext("Choose if you want to activate this card"),
            "" , "", "" , "Yes :t, - No:f",   "", "", "", "" );
I hope this is enough to get you going.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 1:52 pm 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 2:19 pm 
Offline
Moderator
User avatar

Joined: Thu Jun 22, 2006 2:19 pm
Posts: 2890
Location: Devon, UK
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 2:38 pm 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 4:22 pm 
Offline
Moderator
User avatar

Joined: Thu Jun 22, 2006 2:19 pm
Posts: 2890
Location: Devon, UK
mazhar996 wrote:
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.
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.
Quote:
btw have you ever tried adding a new field in signup page?
No.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 6:38 pm 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
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?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 7:02 pm 
Offline
Moderator
User avatar

Joined: Thu Jun 22, 2006 2:19 pm
Posts: 2890
Location: Devon, UK
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 9:08 pm 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 10:04 pm 
Offline
User avatar

Joined: Mon Apr 30, 2007 6:43 am
Posts: 1060
Location: Canada
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 12:08 am 
Offline
Moderator
User avatar

Joined: Thu Jun 22, 2006 2:19 pm
Posts: 2890
Location: Devon, UK
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"),
            "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."));
This depends on a new regular expression in Class.FormHandler.inc.php:
Code:
      // 20  TEXT 'Y', 'y', 'T', 't' or '1'
      $this -> FG_regular[]  = array(   '^[TtYy1]$', '');
This seems to function well.


Attachments:
File comment: against branches/1.3 r615
signup-terms.diff.txt [3.24 KiB]
Downloaded 248 times
Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 20, 2008 2:44 pm 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
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


Attachments:
FG_var_index.inc.txt [11.95 KiB]
Downloaded 244 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 
Hosted Voice Broadcast


All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group