This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

krdr
krdr

Each form field can be "hidden". Whatever I do, whatever type I set, OctoberCMS creates a <div> element, without <input type='hidden'> element and without any value attached to it. Of course, when form is posted, no value is sent.

It would be great if someone points me to the right usage of "hidden " or how to achive <input type="hidden"> functionality.

Last updated

jfo
Parsec
Parsec

What are you using? I just create the fields in my templates using normal HTML mixed with TWIG. That works fine for me.

Crazymodder
Crazymodder

Hi Parsec,

October Backend Forms also provide an attribute:

hidden  hides the field from the view. Options: true, false.
Pat Och
Pat Och

hi bros,

Please, could a october designer answer the question? (or anyone)

what is the purpose to define a form field with hidden = true or visibility = false options which is not visible in the displayed page (ok for that part) nor in $_POST array (for this part, hmmmmm) ?

i try to define a hidden field in a repeater form and obviously i would like to see the field in my $_POST and better, in the json field produced

thank you in advance for some light, regards

daftspunky
daftspunky

You can pass attributes with the form field

myfield:
    attributes:
        hidden: true

Or you can set type: partial and use any input type you like.

Arajay
Arajay

The native "hidden" attribute strips the input from the DOM altogether. What we're trying to do is pass form data without displaying the form input in the backend (normally you would use input type="hidden").

I have tried hidden: true and disabled: true; both remove/disable the input, but neither of them will POST the data! Is there no way to define an input as "hidden" via the YAML config?

Last updated

jacky30257
jacky30257

+1

another way

    public function formBeforeSave($model){
        $model->xxx= 'xxxx';
    }

Last updated

walidh9326228
st.james.jomuad13119
st.james.jomuad13119

jacky30257 said:

+1

another way

   public function formBeforeSave($model){
       $model->xxx= 'xxxx';
   }

Thanks... this works

josh208
josh208

daftspunk said:

You can pass attributes with the form field

myfield:
   attributes:
       hidden: true

Or you can set type: partial and use any input type you like.

Simply setting an element attribute to hidden does not hide it. But by including the following CSS, this will work and certainly makes this an easy approach (I just added this to my theme's default layout so I can use it anywhere)

input[hidden="1"] { display: none }

Last updated

st.james.jomuad13119
st.james.jomuad13119

To get the post value use: post()

1-12 of 12

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.