This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 3
[closed] Remove DD from date field...?
Started 12 years ago by tmparisi | 6 posts |
-
Is there a way to remove the 'DD' portion of the date field from a specific form, say form #8, where the date field is attribute_12. I am using it for a credit card expiration field and the day is not needed and only becomes confusing for users. Thanks!
Posted 12 years ago # -
What is the date format you are using? MM/DD/YYYY or DD/MM/YYYY?
MachForm Founder
Posted 12 years ago # -
MM/DD/YYYY
Posted 12 years ago # -
You can edit "includes/view-functions.php" file, search around line 1180 for this code:
return $element_markup;
right above that line of code, add this block of code:
if($element->form_id == 8 && $element->id == 12 ){ $element_markup = <<<EOT <li id="li_{$element->id}" {$li_class}> <label class="description">{$element->title} {$span_required}</label> <span> <input id="element_{$element->id}_1" name="element_{$element->id}_1" class="element text" size="2" maxlength="2" value="{$default_value_1}" type="text" /> / <label for="element_{$element->id}_1">{$mf_lang['date_mm']}</label> </span> <span style="display:none"> <input id="element_{$element->id}_2" name="element_{$element->id}_2" class="element text" size="2" maxlength="2" value="1" type="text" /> <label for="element_{$element->id}_2">{$mf_lang['date_dd']}</label> </span> <span> <input id="element_{$element->id}_3" name="element_{$element->id}_3" class="element text" size="4" maxlength="4" value="{$default_value_3}" type="text" /> <label for="element_{$element->id}_3">{$mf_lang['date_yyyy']}</label> </span> {$guidelines} {$error_message} </li> EOT; }
if the above code doesn't display correctly in this forum, you can check this one instead:
http://pastie.org/4381082MachForm Founder
Posted 12 years ago # -
In my code it was more like line #1236 but I copied that as requested and modified the form_id and element_id to match my specific form (even tripple checked that info) and it still didn't work. It displays as three dates still. I see that it will hide the DD form via CSS, but that won't pass validation will it? Since it is an invalid date without the day field.
Ultimately it would be better if this format was a part of the "date format" drop down, so along with the option of MM/DD/YYYY you would also see a MM/YYYY option there. I know that may involve more coding than a simple copy/paste but it would be better than hard-coding it in the script. Just in case the element ID ever changes or the script is upgraded later.
CORRECTION: I put it too far down, it was actually around line 1023 and i it did display (in the form) correctly. I had to remove the date checking from the field (although I could keep the "required" entry) to get it to work. But my second comment still stands. This fix is a good temporary fix.
P.S. I am able to get around the security issue with credit cards because my machforms are ONLY accessible via SSL, the data is only read through the machform website and no email is sent. I delete the message after the card processes. It may not be 100% PCI compliant but it is pretty close.
Posted 12 years ago # -
This worked perfectly, thanks!
Posted 12 years ago #
Topic Closed
This topic has been closed to new replies.