Jump to content

Add markup to single field


guy
 Share

Recommended Posts

Is there a method to add markup to a single input field when building a form?

At present I'd customise the forms markup:

$form = $modules->get("InputfieldForm");

$form->setMarkup([
    'item_content' => "{out}<span class='custom-span'></span>",
    ....
]);

Which works but adds the custom span to every inputFieldWrapper. Adjusting setMarkup on an individual field, i.e.

$field = $modules->get("InputfieldText");

$field->setMarkup([
    'item_content' => "{out}<span class='different-span'></span>"
]);

Calls the same method, setting $markup within inputFieldWrapper.php and adjusting the output of every inputFieldWrapper

Therefore I was hoping for a way of appending to the inputfield or wrapper without it being global

  • Like 1
Link to comment
Share on other sites

It's just another Inputfield to be used with processwire's form api. Instead of rendering a "real" inputfield you can just set a string (markup) to it, that will then be plainly rendered, without looking at it. What I just noticed: I was wrong above, just using it for opening and closing markup won't work as InputfieldMarkup is also wrapped in the "wrappingMarkup" that every other Inputifield does get, too.

Edit: The holy bible for working with the form api: https://processwire.com/talk/topic/2089-create-simple-forms-using-api/

Link to comment
Share on other sites

but it refers to coding in the admin? i haven't done any form coding yet so that's why i have no idea ;) my question was more about if there was a kind of installable inputfield (click, click solution) with a textarea that you can then place to a template (click, click) and then it renders some markup for you.

edit: InputfieldMarkup is not that kind of a field, is it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...