Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
A Zayed Posted February 11, 2019 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
Sonya* Posted February 11, 2019 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>
Ryan Ashbrook Posted February 11, 2019 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 );
A Zayed Posted February 12, 2019 Author 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
Recommended Posts
Archived
This topic is now archived and is closed to further replies.