Jump to content

Recommended Posts

Posted

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
Posted

That's not possible right now, you could only use InputfieldMarkup before and after your inputfield to add wrapping markup around the whole inputfield.

  • Like 1
Posted

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/

Posted

sorry for hijacking this thread, but this is for frontend forms, right? is it also possible to have some custom markup in admin forms, eg links in descriptions or such?

Posted

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?

Posted

InputfieldMarkup is only the inputfield, but there's no corresponding fieldtype, that you could create a field from. It's more a tool for module creation and custom backends.

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
×
×
  • Create New...