fabrik icon indicating copy to clipboard operation
fabrik copied to clipboard

Textarea element is hidden in form if the element was converted from a hidden field

Open robho opened this issue 2 years ago • 4 comments

To Reproduce

  1. Create a form with a "field" element.
  2. Set the element to "Hidden".
  3. Change the element to a "textarea" element.
  4. Now the textarea element is hidden in the form and you have to convert the element back to a field element in order to set hidden = false.

Expected behavior Either

  • The hidden attribute should be toggleable for other element types than field or
  • The hidden attribute should only be used when the element is of type field

Actual behavior The textarea element is hidden in the form view and there's no way to "unhide" unless the element is converted to type field.

robho avatar Dec 28 '22 21:12 robho

This is the same behaviour as in Fabrik3.

trob avatar Dec 28 '22 22:12 trob

Yes, changing element types messes with the params. Some params may have equivalent properties between fields, yet others properties do not. The issue is if you change an element for field to textarea, and we wipe the values for any that do not apply, then switch back to field, how is this to be handled?

My opinion is that if you are going to change the element type, delete the existing element and create a new one.

skurvish avatar Dec 28 '22 22:12 skurvish

@skurvish "Hidden" is special as it's a column in #_fabrik_elements, not in params. So the switch could be added without messing params. But as I said it's only "nice to have".

@robho If you change an element plugin you should know what you are doing anyway. It may also change the DB column type which can introduce a lot more issues (e.g. data loss by truncation or converting to int etc).

trob avatar Dec 29 '22 07:12 trob

Because of this switch lack I was handling similar cases directly in the DB in #_fabrik_elements changing 'hidden' value to 0/1 when it was safe to do. Fully agree with @trob it's nice to have.

dimoss avatar Dec 30 '22 07:12 dimoss