Support

Account

Home Forums General Issues Adding the_field(''); to an input value="" attribute?

Solving

Adding the_field(''); to an input value="" attribute?

  • Afternoon,

    I’ve created a custom php form and added the_field(‘item’); to the value=”” attribute of a hidden input field. Everything works as intended but when I view source within the browser, the form is broken after the value=”” attribute.

    Is there a specific way to add the_field(‘item’); to the value=”” attribute without the code breaking? My snippet is below – wondering if anyone else has achieved this?

    Code:
    <input type="hidden" id="resource" name="resource" value="<?php the_field('item_url'); ?>">

    Any help would be appreciated.

  • What type of field is “item_url”? if there are return settings for the field, what are they? What exactly is being inserted into the value attribute? How is it broken?

  • Thanks for the reply, I think I may have figured it out (not enough coffee). Here are the screenshots showing the break: https://imgur.com/a/fZFdNkl and you can see the code and the view source result.

  • I can’t see the output code past value=" so I still can’t tell much.

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

The topic ‘Adding the_field(''); to an input value="" attribute?’ is closed to new replies.