Forums / General Questions / How to add ID to zen_draw_form?

How to add ID to zen_draw_form?

Views: 37,506

Results 1 to 9 of 9
19 Feb 2016, 4:20 PM
#1
vermontwoods avatar

vermontwoods

New Zenner

Join Date:
Nov 2014
Location:
Corbin
Posts:
2
Plugin Contributions:
0

How to add ID to zen_draw_form?

Hi all,

I am wondering how I can add an ID to a Zen Cart form. Here is the code for the form:

<?php echo zen_draw_form('catalogForm', zen_href_link(FILENAME_CATALOG)); ?>

When I view the source code of the page, I see that this code produces a <form> tag that includes name="catalogForm". I want to add id="catalogForm" as well.

Thanks!

19 Feb 2016, 4:47 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: How to add ID to zen_draw_form?

<?php echo zen_draw_form('catalogForm', zen_href_link(FILENAME_CATALOG)[B], 'post', 'id="catalogForm"'[/B]); ?>
19 Feb 2016, 5:10 PM
#3
vermontwoods avatar

vermontwoods

New Zenner

Join Date:
Nov 2014
Location:
Corbin
Posts:
2
Plugin Contributions:
0

Re: How to add ID to zen_draw_form?

Thank you lat9, that worked perfectly!

4 Sep 2019, 5:47 PM
#4
newagekat avatar

newagekat

Zen Follower

Join Date:
Nov 2005
Location:
Vancouver, Canada
Posts:
151
Plugin Contributions:
0

Re: How to add ID to zen_draw_form?

Hello Lat9

I tried adding an ID to my contact form, but when I send the form it just reloads the page with some of the fields filled out. the only difference between your example and mine is SSL and action=send. Here's my code:

<?php 
/** 
* removing ID from form worked
* readded ID, no go
* changed ID from contact_form to contactForm, no go
*/
?>
<?php echo zen_draw_form('contact_us', zen_href_link(FILENAME_CONTACT_US,'id="contactForm"', 'action=send', 'SSL')); ?>

could you guide me? I'm using zc1.5.5

KP

4 Sep 2019, 6:31 PM
#5
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: How to add ID to zen_draw_form?

newagekat:

Hello Lat9

I tried adding an ID to my contact form, but when I send the form it just reloads the page with some of the fields filled out. the only difference between your example and mine is SSL and action=send. Here's my code:

<?php /** * removing ID from form worked * readded ID, no go * changed ID from contact_form to contactForm, no go */ ?> <?php echo zen_draw_form('contact_us', zen_href_link(FILENAME_CONTACT_US,'id="contactForm"', 'action=send', 'SSL')); ?>
> 
> could you guide me?  I'm using zc1.5.5
Sure, try this instead:
<?php echo zen_draw_form('contact_us', zen_href_link(FILENAME_CONTACT_US, 'action=send', 'SSL'), 'post', 'id="contactForm"'); ?>
4 Sep 2019, 6:49 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: How to add ID to zen_draw_form?

By the time I decided to go ahead and post the same solution as above (checking for response before doing so) it was already posted. :) deleted my original response.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

4 Sep 2019, 7:16 PM
#7
newagekat avatar

newagekat

Zen Follower

Join Date:
Nov 2005
Location:
Vancouver, Canada
Posts:
151
Plugin Contributions:
0

Re: How to add ID to zen_draw_form?

Thank you lat9 and MC12345678, this worked!

MC12345678 i sent you a pm.

KP

21 Feb 2020, 5:10 PM
#8
newagekat avatar

newagekat

Zen Follower

Join Date:
Nov 2005
Location:
Vancouver, Canada
Posts:
151
Plugin Contributions:
0

Re: How to add ID to zen_draw_form?

Lat9 or MC12345678

Thank you again for your help on these. The client wants to add additional tracking to various forms and I manage to get all of them done, but have had no success with the logins.

If I wanted to also add an ID to split logn and the header login on this page https://customironworks.com/login.html, would the same code modification apply?

I noticed that split login already has an action=process

<?php echo zen_draw_form('login', zen_href_link(FILENAME_LOGIN, 'action=process' . (isset($_GET['gv_no']) ? '&gv_no=' . preg_replace('/[^0-9.,%]/', '', $_GET['gv_no']) : ''), 'SSL'), 'id="loginForm"'); ?>

however, the ID does not show on the form when you view source and placing the 'post' does not process the form, it just reloads the same page. I've tried various combinations, but the only one that works is the original code.

for the header I've added the same in the sidebox/tpl_login_header.php like this

if(!$_SESSION['customer_id']) {
  echo zen_draw_form('account_box', zen_href_link(FILENAME_LOGIN, 'action=process', 'SSL'), 'post', 'id="loginForm"');

I also need to add scripts below the form tag, but not sure where to place that

</fieldset></form>\n";
```  before the \n" ??  having it below the </form> of split login is not sufficient as users can login from any page.  Maybe this particular one should be just before the </body>

I really appreciate the assistance.  Thank you.

KP

21 Feb 2020, 9:18 PM
#9
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: How to add ID to zen_draw_form?

newagekat:

Lat9 or MC12345678

Thank you again for your help on these. The client wants to add additional tracking to various forms and I manage to get all of them done, but have had no success with the logins.

If I wanted to also add an ID to split logn and the header login on this page https://customironworks.com/login.html, would the same code modification apply?

I noticed that split login already has an action=process

<?php echo zen_draw_form('login', zen_href_link(FILENAME_LOGIN, 'action=process' . (isset($_GET['gv_no']) ? '&gv_no=' . preg_replace('/[^0-9.,%]/', '', $_GET['gv_no']) : ''), 'SSL'), 'id="loginForm"'); ?>
> 
> however, the ID does not show on the form when you view source and placing the 'post' does not process the form, it just reloads the same page.  I've tried various combinations, but the only one that works is the original code.  
> 
> for the header I've added the same in the sidebox/tpl_login_header.php like this
> ```html
if(!$_SESSION['customer_id']) {
  echo zen_draw_form('account_box', zen_href_link(FILENAME_LOGIN, 'action=process', 'SSL'), 'post', 'id="loginForm"');

I also need to add scripts below the form tag, but not sure where to place that

</fieldset></form>\n"; ``` before the \n" ?? having it below the </form> of split login is not sufficient as users can login from any page. Maybe this particular one should be just before the </body> > > I really appreciate the assistance. Thank you. For the first form, it's missing the indication of how the data should be passed (post or get) which is expected in the position where the current id parameter is placed. So instead of: ```html <?php echo zen_draw_form('login', zen_href_link(FILENAME_LOGIN, 'action=process' . (isset($_GET['gv_no']) ? '&gv_no=' . preg_replace('/[^0-9.,%]/', '', $_GET['gv_no']) : ''), 'SSL'), 'id="loginForm"'); ?> ``` It should be: ```html <?php echo zen_draw_form('login', zen_href_link(FILENAME_LOGIN, 'action=process' . (isset($_GET['gv_no']) ? '&gv_no=' . preg_replace('/[^0-9.,%]/', '', $_GET['gv_no']) : ''), 'SSL'), 'post', 'id="loginForm"'); ?> ```

As far as placing the javascript, when you say that someone can login from any page, are you saying that on any given page there are blanks to be filled in to provide access or are you referring to the existence of a link that would take one to the login page? If the first is true, that it will need to fire on any page, then it could be placed/pulled at the start of the page load or could be part of the main_page code or in some way off of the footer area. Otherwise before or after the \n would be okay provided the content is properly put to the browser.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...