-
AuthorPosts
-
July 21, 2017 at 7:16 pm #825213
Hello, I would like to add an icon to the form submit button like a normal enfold button element.
I have tried adding HTML to submit label field, but HTML doesn’t work in that field. I tried adding a short code in and it failed as well.
Any suggestions?
July 22, 2017 at 8:51 am #826840July 22, 2017 at 5:34 pm #828413You are correct Mike, I tried that. The shortcode won’t save in that form. It is just a basic form nothing special about it. I can’t link it because it is in dev behind a firewall. I decided the design could let this one go. I figured I could edit the theme’s PHP file for the form, but that isn’t in my client’s budget. I was hoping for some kind of filter in the themes function file or some kind of CSS trick that would be a quick fix.
I saw a couple forum posts about adding it as a BG image, but that just seemed too sloppy for my taste.
I was thinking there would be a function that could disable the escaping of the HTML for that one field in the form options template, that would allow me to insert the plain HTML markup.
- This reply was modified 7 years, 4 months ago by talawar. Reason: Grammatical error
July 22, 2017 at 10:01 pm #828476well we have on contact form that element :
input.button[type="submit"]
maybe it is possible to prepend some code to that element and style it later via quick cssJuly 22, 2017 at 11:36 pm #828508if we know the html attribute symbol for that icon you can insert it in the input field of contact form element f.e.:
Submit
you only have to setup then :
input.button[type="submit"] { font-family: entypo-fontello; }
but is there a list of that html attribut symbols concerning to entypo-fontello icons ?
July 23, 2017 at 3:37 am #828548I ended up editing the parent theme… framework/php/class-form-generator.php
Line 322
Replace the<input>
tag with<button>HTML that to display</button>
leave all of theThe
<input>
is just too limited to work with using jQuery or Javascript. The value=”” attribute doesn’t do well with HTML.I found the easiest way to get the desired HTML ( a button with an icon ) with the minimal CSS styling adjustments, was to inspect an existing button in the chrome debug window.
Copy the element at this parent div:
<div class="avia-button-wrap avia-button-center el_after_av_hr avia-builder-el-last main_btn">
Remove the identifying class e.g. “avia-builder-el-48″ if your choose to”
The I removeded thehref=""
and change the<a>
tags to<span>
tags.One draw back that I haven’t solved is that the page will now refresh on “SUBMIT.” I don’t feel it is essential to this project but it would be nice to figure this out for the future. It is a bummer that I will have to update the parent everytime…
I used the following CSS to stop the unwanted styling effects:
.avia_ajax_form .button { margin: 0; padding: 0; border-radius: 2px; border-bottom-width: 0; border-bottom-style: none; font-weight: 700; font-size: 0.92em; min-width: 142px; outline: none; } .main_color .button:hover { background:white; }
Finally I added a class, “someclass”, after
class="avia_iconbox_title someclass"
like this to finish the styling.July 23, 2017 at 12:39 pm #828653how do i get that little sign in source code :
data-av_icon=''
there must be a conversion from array icon and icon-select to that sign.
i think of making an edited contact.php shortcode with icon select but that display_char generates me a whole bunch of html.
July 23, 2017 at 1:54 pm #828664@Guenni007 if you are asking how I added the symbol I want to the framework PHP, the simple answer is I copy and paste it.
For example the code below gives me the right arrow icon:
<span class="avia_button_icon avia_button_icon_right" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span>
In order to get the code above in the first place, I create a normal button or stand alone inline icon. Then I “publish/preview” the page. Inspect the icon with the debugger and copy the element.
The problem is that the icon character (the square gylph),
data-av_icon=""
isn’t found until enfold runs it through its fontello code, so that is the easiest way to figure out the proper value fordata-av_icon=""
.July 23, 2017 at 2:52 pm #828678no that is not what i want – i told here https://kriesi.at/support/topic/adding-an-icon-to-the-form-submit-button/#post-828508 that this will be the fastest way to get an entypo-fontello icon to the submit button – you only have to put in that field the copied sign plus Submit text and set up css for font-family than.
red arrowsbut i want to edit the shortcode to have the oportunity to have icons for that button looks this way newfields with blue arrows
but inserting in that input field the
"{$display_char}"." ".$button
ends up ( see preview in image above)
that comes i think from a function in font-manager.class.php
So if i knew how to get via php only the transformed sign without that other stuff – i can insert than that glyph to value of input field.
And share afterwards the edited contact.phpJuly 23, 2017 at 3:10 pm #828684Now I see what you are saying. I still think you need to edit the framework file to make that input into a
<button></button>
tag. The form button field (RED ARROW from your image) is placed into<input type="submit" value="Submit <span class="avia_button_icon avia_button_icon_right" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span>"/>
Am I correct in saying you are getting this:
Submit <span class="avia_button_icon avia_button_icon_right" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span>
instead of thisSubmit >
.Again the root of the problem is trying to put HTML into a data-attribute, which we are limited to with an
<input/>
tag.This StackExchange answer may be what you are looking for https://stackoverflow.com/questions/5823835/html-in-the-input-field-value
I tried replacing the brackets, but it still escaped the HTML.
@Guenni007 Your method would be far superior. Sidenote I always appreciate your answers! You definitely add some amazing solutions on this forum, I applaud your effort!- This reply was modified 7 years, 4 months ago by talawar.
July 23, 2017 at 3:42 pm #828703The image above is two things in one.
so to be clear: if you try only red arrows – that will work with that little css in quick css:
input.button[type="submit"] { font-family: entypo-fontello; }
but the thing is – that a handful of people will know how to copy/paste those glyphs from source code.
i make a button with icon elsewhere and look to the source code. Copy paste that glyph : f.e
and insert it in the submit field as: Submit
so this method only will work if we can offer f.e a table of fontello-icons with there code and with that glyphs.Or the other method for noobs – just edit the
July 23, 2017 at 5:54 pm #828725the input button destroys every method i can imagine !
For some reasons i tried it with embeding fontawesome (functions.php of child-theme) :
add_action( 'wp_enqueue_scripts', 'enqueue_awesome' ); function enqueue_awesome() { wp_enqueue_style( 'prefix-font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', array(), '4.7.0' ); }
and than add the concerning class to the submit button:
function add_class_to_submit() { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('input.button').addClass('fa fa-envelope-open-o'); }); </script> <?php } add_action('wp_footer', 'add_class_to_submit', 20);
this works but font isn’t visible – the pseudo-class before and after did not work
July 23, 2017 at 6:02 pm #828726if i use prepend to input button – the inserted code goes between
<input> and </input>
function prepend_to_submit(){ ?> <script> (function($){ $('input.button[type="submit"]').prepend('<i class="fa fa-envelope-open-o"></i>'); })(jQuery); </script> <?php } add_action('wp_footer', 'prepend_to_submit');
it is in the source code but not visible on some reasons.
right solution by entering in the enfold dialog Submit input field : Submit
left side fontawesome included but not visible
https://webers-testseite.de/kokon/elements/contact-form/- This reply was modified 7 years, 4 months ago by Guenni007.
July 23, 2017 at 6:19 pm #828728You can open the imgur links in a new ta to view the imgs.
I replicated what you have done above.The icon is there, but I believe it will never appear with the
<input>
tags. This is why I had to resort to editing the framework PHP file to change it to a<button>
.I feel like it is way more work to change the behavior of an HTML5 <tag> than to just use the correct <tag>.
- This reply was modified 7 years, 4 months ago by talawar. Reason: Imgs not working
July 28, 2017 at 5:10 am #830883Hi,
Another work around is to add an icon element or shortcode before or after the contact form, add the custom css attribute “form-icon” then use the following script in the functions.php file.
// add submit icon function ava_custom_script_mod(){ ?> <script> (function($){ var icon = $('.form-icon .av-icon-char').data('av_icon'), submit = $('input[type="submit"]'), value = submit.attr('value'); submit.attr('value', icon + ' ' + value); submit.css({ 'font-family' : 'entypo-fontello' }); $('.form-icon').css('display', 'none'); })(jQuery); </script> <?php } add_action('wp_footer', 'ava_custom_script_mod');
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.