Recent Topics

1 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.

3 Oct 14, 2017 01:14

@mgsolipa that is pretty awesome. Thanks! Hope it goes through.

4 Apr 19, 2018 08:40

@fplanque can you please look at this and revert back with feedback?

5 May 01, 2018 10:32

@achillis Please see my attached screenshot.
I think you can do this with modifying your skin:

	function get_template( $name )
	{
		switch( $name )
		{
			case 'your_custom_checkboxes_form':
				return array_merge( $this->get_template( 'Form' ), array(
						'inputstart_checkbox' => '<div class="controls col-sm-9 your_custom_checkbox_wrapper_class">',
						'inputend_checkbox'   => "</div>\n",
						'note_format'         => '<label for="$ID$">%s</label>',
					) );
		}

		return parent::get_template( $name );
	}

then you can use this in your forms like:

	$Form->switch_layout( 'your_custom_checkboxes' );
	$Form->checkbox_input( 'checkbox_name2', 0, '', array( 'note' => T_('Checkbox 2 note') ) );
	$Form->checkbox_input( 'checkbox_name3', 0, '', array( 'note' => T_('Checkbox 3 note') ) );
	$Form->checkbox_input( 'checkbox_name4', 0, '', array( 'note' => T_('Checkbox 4 note') ) );
	$Form->switch_layout( NULL );

Currently the $ID$ is not replaced with proper value in '<label for="$ID$"> yet but if such solution is enough for you, then we can easy implement the $ID$ replacing instead of that implementation for param label_after_input what @mgsolipa did.

6 May 01, 2018 16:06

@yurabakh thank you for this information, since this request is related to a plugin, is it possible for plugins to handle the template instead of a skin? Or regardless of the skin?

7 May 08, 2018 10:12

@yurabakh this solution is not adequate for this issue/request as it complicates things further with adding a <label> tag instead of moving it.


Form is loading...