Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default postcode input field appears way of to the right

    hi,

    I'm having a really strange problem ... the field postcode rendered in tpl_create_account.php appears completely unaligned to the right ... strange because I checked the stylesheet and input fields have all the same rules ... but postcode doesn't follow them ...


    Here is a code excerpt

    Code:
    <label class="inputLabel" for="postcode"><?php echo ENTRY_POST_CODE; ?></label>
    <?php echo zen_draw_input_field('postcode', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', '40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="alert">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?>
    <br class="clearBoth" />
    From there I can see it uses zen_draw_input_field() function, but strangely instead of appear normally the input field is shifted all the way to the right!

    THis is what I mean:
    postcode xxx

    The others:
    city:
    xxx

    Perfectly aligned to the left ...

    why? don't know all the other input fields are properly aligned ...
    and ruled by:
    Code:
    INPUT {
    margin:.3em .5em;
    }
    LABEL.inputLabel {
    width:85%;
    float:left;
    margin:.3em 0;
    }
    plus there are no differences in the php code or anything that might cause this behavior ...

    If anybody has found a solution please let me know ...
    Last edited by icecold; 9 Dec 2008 at 06:43 PM.

  2. #2
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: postcode input field appears way of to the right

    Quote Originally Posted by icecold View Post
    hi,

    I'm having a really strange problem ... the field postcode rendered in tpl_create_account.php appears completely unaligned to the right ... strange because I checked the stylesheet and input fields have all the same rules ... but postcode doesn't follow them ...


    Here is a code excerpt

    Code:
    <label class="inputLabel" for="postcode"><?php echo ENTRY_POST_CODE; ?></label>
    <?php echo zen_draw_input_field('postcode', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', '40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="alert">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?>
    <br class="clearBoth" />
    From there I can see it uses zen_draw_input_field() function, but strangely instead of appear normally the input field is shifted all the way to the right!

    THis is what I mean:
    postcode xxx

    The others:
    city:
    xxx

    Perfectly aligned to the left ...

    why? don't know all the other input fields are properly aligned ...
    and ruled by:
    Code:
    INPUT {
    margin:.3em .5em;
    }
    LABEL.inputLabel {
    width:85%;
    float:left;
    margin:.3em 0;
    }
    plus there are no differences in the php code or anything that might cause this behavior ...

    If anybody has found a solution please let me know ...
    The above problem happens with Firefox 3.04 Opera, IE7 and Chrome renders it fine ...

  3. #3
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: postcode input field appears way of to the right

    Will float the affecting code to the left solve this issue?

    I read the function that renders the input field and there was nothing there that might cause this odd behavior.

    As I said the label is correctly aligned, but the input field appears in the same line and in the far right, instead of below ...

    This is the code that has the error ...
    Code:
    <label class="inputLabel" for="postcode"><?php echo ENTRY_POST_CODE; ?></label>
    <?php echo zen_draw_input_field('postcode', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', '40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="alert">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?>
    <br class="clearBoth" />
    And this is code from another label and field ...
    Code:
    <label class="inputLabel" for="city"><?php echo ENTRY_CITY; ?></label>
    <?php echo zen_draw_input_field('city', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_city', '40') . ' id="city"') . (zen_not_null(ENTRY_CITY_TEXT) ? '<span class="alert">' . ENTRY_CITY_TEXT . '</span>': ''); ?>
    <br class="clearBoth" />
    The difference is the first one doesn't display the input field where it should be ... the latter does ...

    Both call the same function ... and use the same CSS rules ... so why this is happening?

  4. #4
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: postcode input field appears way of to the right

    I isolated the problem but still couldn't solve it ... I replaced the code for the postcode input field by the code for city commenting out the old code and it worked ... so from there I started to debug the problem code ... so far I found if I copy exactly the same code but replacing the entries corresponding to city by the one from postcode, then the error appears again ... It's related to these functions:

    Code:
    // function to return field length
    // uses $tbl = table name, $fld = field name
      function zen_field_length($tbl, $fld) {
        global $db;
        $rs = $db->MetaColumns($tbl);
        $length = $rs[strtoupper($fld)]->max_length;
        return $length;
      }
    
    ////
    // return the size and maxlength settings in the form size="blah" maxlength="blah" based on maximum size being 50
    // uses $tbl = table name, $fld = field name
    // example: zen_set_field_length(TABLE_CATEGORIES_DESCRIPTION, 'categories_name')
      function zen_set_field_length($tbl, $fld, $max=50, $override=false) {
        $field_length= zen_field_length($tbl, $fld);
        switch (true) {
          case (($override == false and $field_length > $max)):
            $length= 'size = "' . ($max+1) . '" maxlength= "' . $field_length . '"';
            break;
          default:
            $length= 'size = "' . ($field_length+1) . '" maxlength = "' . $field_length . '"';
            break;
        }
        return $length;
      }
    This is the line that's causing trouble ...

    Code:
    <?php echo zen_draw_input_field('postcode', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', '40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ?
    I din't know if the value 40 is referred to maxlength, or not
    the argument $max in the above function ...
    Or why it's 40 when the maxlength for that field should be 10 ...
    if anyone can explain the way the function works?

    I might understand why the input value is 40 instead of what I think ... 10

  5. #5
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,378
    Plugin Contributions
    0

    Default Re: postcode input field appears way of to the right

    Does the field align properly if you change the value to 10? I don't see any reason to have it larger anyway.

    Rob

  6. #6
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: postcode input field appears way of to the right

    Well, I was not sure if that might be the issue, so I didn't try it, what I did try was to replace postcode with city, and it worked fine ... I couldn't find anything that might cause this strange behavior ... in the code, nor in DEFINEs, or the css, I even tried to add a css rule for #postcode INPUT {float:left;} but that didn't work either ...

    I will try replacing 40 with 10 and see what happens ...

    thanks for the tip ...

  7. #7
    Join Date
    Jul 2008
    Posts
    360
    Plugin Contributions
    0

    Default Re: postcode input field appears way of to the right

    I found the parent function

    Code:
    ////
    // Output a form input field
      function zen_draw_input_field($name, $value = '', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) {
        $field = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"';
    
        if (isset($GLOBALS[$name]) && ($reinsert_value == true) && is_string($GLOBALS[$name])) {
          $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
        } elseif (zen_not_null($value)) {
          $field .= ' value="' . zen_output_string($value) . '"';
        }
    
        if (zen_not_null($parameters)) $field .= ' ' . $parameters;
    
        $field .= '>';
    
        if ($required == true) $field .= TEXT_FIELD_REQUIRED;
    
        return $field;
      }
    It's still not clear why the value is 40 ...
    Anyway I changed all instances to 10 and it didn't work either ...

    If someone with a good knowledge of these functions can explain why this is happening it will be really appreciated ...

  8. #8
    Join Date
    May 2006
    Location
    Scotland
    Posts
    198
    Plugin Contributions
    0

    Default Re: postcode input field appears way of to the right

    Did anyone ever solve this as I have the same problem?

  9. #9
    Join Date
    May 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: postcode input field appears way of to the right

    Hi, have been trying to fix this on and off for months, then finally cracked it- I just added a clearBoth between the label and the field, so change this:

    PHP Code:
    <label class="inputLabel" for="postcode"><?php echo ENTRY_POST_CODE?></label>
    <?php echo zen_draw_input_field('postcode'''zen_set_field_length(TABLE_ADDRESS_BOOK'entry_postcode''40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="alert">' ENTRY_POST_CODE_TEXT '</span>'''); ?>
    <br class="clearBoth" />
    to this
    PHP Code:
    <label class="inputLabel" for="postcode"><?php echo ENTRY_POST_CODE?></label>
    <br class="clearBoth" />
    <?php echo zen_draw_input_field('postcode'''zen_set_field_length(TABLE_ADDRESS_BOOK'entry_postcode''40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="alert">' ENTRY_POST_CODE_TEXT '</span>'''); ?>
    <br class="clearBoth" />
    Hope this helps!

 

 

Similar Threads

  1. Make input field on collectinfo also display the field text as hyperlink
    By jpietrowiak in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 15 Dec 2012, 05:06 AM
  2. How would I move the template all the way to the right and fix an image to the
    By pityocamptes in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 15 Sep 2010, 05:45 AM
  3. Easiest way to change the width on the right an left nav/boxes?
    By ThomasT in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 7 Jul 2010, 01:42 AM
  4. what is the right way 1.3.0.1->1.3.8a?
    By eternity575 in forum Upgrading from 1.3.x to 1.3.9
    Replies: 7
    Last Post: 9 Jul 2009, 07:26 PM
  5. Hide Postcode field in shipping Estimator?
    By Ryk in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 10 Dec 2007, 10:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR