Support

Account

Home Forums Feature Requests Wrap fields' textarea in div (for styling/positioning)

Solved

Wrap fields' textarea in div (for styling/positioning)

  • A very, very minor request:

    I am trying to make the backend a little more compact, in particular move the label left to the input field. Which is actually not that hard using a little CSS pulled in, floating the label.

    Currently, input fields (as well as checkboxes and so on) are wrapped in a div (div.acf-input-wrap). Incidentally, it comes with overflow:hidden already set, which is perfect since it then takes the remaining horizontal space beside a floated element. However, there’s textareas, and they can’t be treated the same way since they are not wrapped but rather inserted directly.

    The solution to this would be to simply wrap the textarea field into a div, too, maybe div.acf-textarea-wrap to keep with the nomenclature. This div would not need any styling whatsoever, only provide an element the CSS can apply to if needed.

    The code change is trivial. For obvious reasons, I do not want to edit the source, and wrapping the textarea via jQuery would only be a workaround I believe.

  • Hi @dreamer

    Thanks for the request!

    Ive passed it on to Elliot

  • Came up with a solution in the meantime… Just requires adding a few lines to your theme’s functions.php file:

    
    function greenbg_shortcode($params, $content = null) {
    	extract(shortcode_atts(array(
    		'field' => ''
    	), $params));
    
    	if($field != '') {
    		return '<div class="full-width green-bg">'.get_field($field).'</div>';
    	} else {
    		return null;
    	}
    }
    add_shortcode('greenbg','greenbg_shortcode');
    

    It uses the same syntax as the default ACF shortcode (so you’ll still need to specify the field=”field_name” part), like so:

    [greenbg field="green-bg-copy"]

  • deepfriedfilth, I have no idea how that would have been a solution to the problem.

    However, with the release of ACF 5 and its new layout this feature request has, obviously, become obsolete.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Wrap fields' textarea in div (for styling/positioning)’ is closed to new replies.