A Zayed Posted February 11, 2019 Share Posted February 11, 2019 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 Link to comment Share on other sites More sharing options...
Sonya* Posted February 11, 2019 Share Posted February 11, 2019 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> Link to comment Share on other sites More sharing options...
Ryan Ashbrook Posted February 11, 2019 Share Posted February 11, 2019 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 ); Link to comment Share on other sites More sharing options...
A Zayed Posted February 12, 2019 Author Share Posted February 12, 2019 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.