This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Take the "Seconds" option out of the "Time" element


  1. Al
    Member

    How many people will be using this option? I need to use the element but just hours and minutes.

    Posted 17 years ago #
  2. yuniar

    More people are asking this one, so I'll definitely provide an option to remove the seconds field. For now, please follow the instruction below:

    Modify your includes/view-functions.php file. Search around line 705 (inside display_time() function), you'll find this code:

    <span>
       <input id="element_{$element->id}_3" name="element_{$element->id}_3" class="element text " size="2" type="text" maxlength="2" value="{$element->populated_value['element_'.$element->id.'_3']['default_value']}"/>
       <label>SS</label>
    </span>


    Remove that code.
    After that, modify includes/post-functions.php, search around line 354, look for these code:

    $element_name_2 = substr($element_name,0,-1).'2';
    $element_name_3 = substr($element_name,0,-1).'3';
    $element_name_4 = substr($element_name,0,-1).'4';


    Right under those lines, add the code below:

    $user_input[$element_name_3] = '00';


    This way, the seconds would be default to 00.

    Let me know if you have any difficulty.


    MachForm Founder

    Posted 17 years ago #
  3. Al
    Member

    It does and it does not work. While it does delete the seconds column, there is an error at the top of the page when viewing the form and the header is not correct. It has something to do with the includes/view-functions.php file when I change it. The error goes away and the seconds come back when I put the code back in for
    <span>
    <input id="element_{$element->id}_3" name="element_{$element->id}_3" class="element text " size="2" type="text" maxlength="2" value="{$element->populated_value['element_'.$element->id.'_3']['default_value']}"/>
    <label>SS</label>
    </span>

    Posted 17 years ago #
  4. Al
    Member

    Here is the error code on top:
    Warning: Cannot modify header information - headers already sent by (output started at /home/content/p/o/e/poetsstudy/html/orderforms/includes/view-functions.php:1) in /home/content/p/o/e/poetsstudy/html/orderforms/view.php on line 67

    Posted 17 years ago #
  5. yuniar

    ok, thats weird. the error seems to be on line 1 of view-functions.php

    make sure you don't have any spaces/new lines at the first line ( before the <?php tag )


    MachForm Founder

    Posted 17 years ago #
  6. yuniar

    Could be text editor problem. Are you using notepad? Try to use wordpad and save the file again.

    If that still doesn't work, please send me your view-functions.php file to customer.service [at] appnitro.com

    I'll take a look.


    MachForm Founder

    Posted 17 years ago #
  7. Al
    Member

    Yes I'm using Notepad because the Wordpad will only let me save it as (RTF; TEXT DOCUMENT; TEXT DOCUMENT-MS DOS FORMAT; UNICODE TEXT DOCUMENT) and it says it will remove all formatting.

    Posted 17 years ago #
  8. yuniar

    Ok, this seems indeed a text editor problem. Notepad is not so good for this.
    If you don't have any other text editor, I suggest to use WordPad and just ignore the warning it says (remove all formating..etc).

    Even better, you might want to use this powerful editor:
    http://notepad-plus.sourceforge.net/uk/site.htm

    It's free and very good.


    MachForm Founder

    Posted 17 years ago #
  9. Al
    Member

    Thank you for fixing the problem for me in my website. You are sooOOOOooo helpful.
    I'll look into the program in two seconds.

    Posted 17 years ago #
  10. yuniar

    Glad to help :-)


    MachForm Founder

    Posted 17 years ago #
  11. vrenda
    Member

    This work for me unless the time was left blank.

    We are using this form for time sheets.
    If someone did not work Monday and left the "IN' & "OUT" blank we receive an error:

    "This field is not in the correct time format"

    Any suggestions?

    Posted 16 years ago #
  12. yuniar

    Oh, you are absolutely right! Sorry that was my fault.

    Ok, change this line:

    $user_input[$element_name_3] = '00';

    With this one:

    if(!empty($user_input[$element_name])){
    	$user_input[$element_name_3] = '00';
    }

    MachForm Founder

    Posted 16 years ago #
  13. vrenda
    Member

    After we did this, the form is processed but the email sent has the blank time defaulted with 7:00am.

    Posted 16 years ago #
  14. yuniar

    Hmm.. try to do one more patch below:

    Edit your includes/post-functions.php file, search around line 386.
    You'll find this code:

    $target_input['element_time_no_meridiem']=@date("G:i:s",strtotime($target_input['element_time']));

    Replace that line with this one:

    if(!empty($user_input[$element_name])){
    	$target_input['element_time_no_meridiem'] = @date("G:i:s",strtotime($target_input['element_time']));
    }


    If that doesn't work either, I'll need to directly check your server.


    MachForm Founder

    Posted 16 years ago #
  15. hermann
    Member

    Hello yuniar,

    please also concern to get rid of the AM/PM drop down. In Germany we don't have this, we use 24h.

    I think it will be nice to have an checkbox option under the "Field Label/Field Type" called something like "use seconds" and "use AM/PM".

    However, thanks for the wonderful script.
    Best,
    Hermann

    Posted 16 years ago #
  16. yuniar

    Thanks Hermann,

    That's definitely a great idea!


    MachForm Founder

    Posted 16 years ago #

RSS feed for this topic

Reply