Jump to content

Time Frame Form Field


A Zayed

Recommended Posts

Posted

Is there a built in form class in the FormAbstract that allows me create Time Frame form field?

For example:

From "00:30" to "02:00"

I know there's Date class with time option, but I need only time not date or datetime

Posted

You can use custom field with template.

        $form->add(new \IPS\Helpers\Form\Custom('mytime', $mytime, false, array(
            'getHtml' => function ($element) {
                return \IPS\Theme::i()->getTemplate('fields')->mytimeField('mytime', $element->value);
            }
        )));

And then define a time field in the html template:

<ips:template parameters="$name, $value" />
<div>
    <input type='time' class='ipsField_short' placeholder='' value="{$value}" name="$name">
</div>

 

Posted

You can also specify the type of field when using \IPS\Helpers\Form\Text.

$form = new \IPS\Helpers\Form;
$input = new \IPS\Helpers\Form\Text( 'my_field', $value, TRUE );
$input->formType = 'time';
$form->add( $input );

 

Posted
18 hours ago, Ryan Ashbrook said:

You can also specify the type of field when using \IPS\Helpers\Form\Text.


$form = new \IPS\Helpers\Form;
$input = new \IPS\Helpers\Form\Text( 'my_field', $value, TRUE );
$input->formType = 'time';
$form->add( $input );

 

Excellent... 

19 hours ago, Sonya* said:

You can use custom field with template.


        $form->add(new \IPS\Helpers\Form\Custom('mytime', $mytime, false, array(
            'getHtml' => function ($element) {
                return \IPS\Theme::i()->getTemplate('fields')->mytimeField('mytime', $element->value);
            }
        )));

And then define a time field in the html template:


<ips:template parameters="$name, $value" />
<div>
    <input type='time' class='ipsField_short' placeholder='' value="{$value}" name="$name">
</div>

 

Didn't use custom form before, will try this solution also

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...