Jump to content

Create form via API: InputfieldHidden label is shown?


Stefanowitsch
 Share

Recommended Posts

This question is maybe trivial but I found no solution. When generating a form with the processwire API I want to make use of some hidden fields. When generating these fields the corresponding label is always shown in the frontend. Which in my opinion makes no sense (it's a hidden field, though!).

This is the code I am using. 

$field = $modules->get("InputfieldHidden");
$field->attr('name','Name');
$form->append($field);

On my form page in the frontend I then see a label called "Name" but no input (which is fine).

The only solution that comes to my mind is to hide the label of the hidden field via CSS but that is not a clean solution.

Link to comment
Share on other sites

Wow that does the trick. Thanks a lot. The skip label markup syntax looks a bit weird at first but now I see that it is a mighty tool.

I assumed that you just could write skipLabel = true.

So the markup returns a number that the code is then working with. This does the same:

$field->skipLabel = 8;

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...