0

Using Solspace User and the {exp:user:edit} form, is it possible to to create an HTML links that has the same function as the button:

<input type="submit" name="remove_photo" value="Remove Current Photo?" />

I can't achieve the styling I want using an input button element.

1

The key for the avatar to be removed is to submit form data for "remove_photo". This means that you need an HTML form field for this to work. Hyperlinks are not form fields.

You can, however, trigger the form submission with a value "remove_photo" by using javascript/jQuery. The "remove_photo" field can be a hidden field as well. For example, if you had:

{exp:user:edit form:class="user_edit"}
    <a href="#" class="remove_photo">Remove Photo</a>
    <input type="hidden" name="remove_photo" value="Remove Current Photo?" />
{/exp:user:edit}

You could use a script like this, for example:

$(document).ready( function () {
    $("a.remove_photo").click(function () {
        $("form.user_edit").submit();
    });
});
1
  • That's perfect. Thanks for the very helpful answer. – Benek Lisefski Jan 19 '14 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.