Recent Topics

Form class - Form inputs format (checkbox)

Started by on Oct 04, 2017 – Contents updated: Oct 14, 2017

Oct 04, 2017 09:27    

re: /inc/_core/ui/forms/_form.class.phps.php

@fplanque and @mgsolipa could the dev consider allowing configurable Template Params that permits form input type formatting?

For example: if I include a form input[type='checkbox'] then this is what we get:

'inline' => false; ==== <field_start><label><input><field_end>

or

'inline' => true; ==== <field_start><label_start><input><label_end><field_end>

What I am hoping to achieve is this format: <field_start><input><label><field_end>

Currently, the workaround is to replace:

$Form->checkbox_input( $field_name, $field_checked, $field_label, $field_params );

with:


// Define some params:

$field_params = array( 
						'hide_label'				=>	$set_hide_label, 
						'class'						=>	$field_class, 
						'note'						=>	$field_note, 
						'required'					=>	$field_required,
						'value' 					=>	1,
						'name'  					=>	$field_name,
						'label' 					=>	$field_label,
						'type'  					=>	'checkbox',
						'checked'  					=> ( ( $field_checked ) ? 'checked': ''),
						);
// Get the checkbox
				$r 	= $Form->get_input_element( $field_params );
				$r .= $Form->begin_field( NULL, NULL, false, $field_params['type'] );
				$r .= $Form->end_field( $field_params['type'] );
				$Form->display_or_return( $r );

The reason why this is useful is to allow custom styled checkboxes (or radio inputs) with styling such as:

input[type='checkbox'] + label {
// rules...
}

input[type='checkbox']:checked + label {
// rules...
}

This is not possible if the label opening tag proceeds the input element.

This post has 1 feedback awaiting moderation...


Form is loading...

multiblog platform – This forum is powered by b2evolution CMS, a complete engine for your website.